← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

HTML and CSS lesson 17: Which CSS rule wins? · Set 7 · 40 questions
TalentJR

Code tip (Stronger first, then later): Strength: #id > .class > element. The stronger selector wins, wherever it is written. Equal strength: the later rule wins.

NameDateTime takenScore ___ / 40
  1. 1.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the shorter one (b) the first one (c) neither (d) the later one
  2. 2.⚖️ Which selector is the weakest? (a) an element selector (b) a class selector (c) an id selector
  3. 3.⚖️ What colour is the text of this element?
    <h1 class="red" id="end">Hi</h1>
    CSS:
    h1 { color: red; }
    h1 { color: yellow; }
    (a) yellow (b) purple (c) red (d) blue
  4. 4.⚖️ What colour is the text of this element?
    <h1 class="menu" id="hero">Hi</h1>
    CSS:
    .menu { color: green; }
    .menu { color: yellow; }
    (a) yellow (b) orange (c) green (d) black
  5. 5.⚖️ What colour is the text of this element?
    <h1 class="note" id="main">Hi</h1>
    CSS:
    #main { color: yellow; }
    #main { color: white; }
    (a) orange (b) red (c) yellow (d) white
  6. 6.⚖️ What colour is the text of this element?
    <h2 class="note" id="hero">Hi</h2>
    CSS:
    .note { color: white; }
    .note { color: blue; }
    (a) white (b) blue (c) red (d) orange
  7. 7.⚖️ Which selector is the strongest? (a) a class selector (b) an id selector (c) an element selector
  8. 8.⚖️ What colour is the text of this element?
    <h1 class="menu" id="hero">Hi</h1>
    CSS:
    .menu { color: green; }
    .menu { color: white; }
    (a) green (b) blue (c) white (d) purple
  9. 9.⚖️ What colour is the text of this element?
    <h2 class="box" id="end">Hi</h2>
    CSS:
    h2 { color: blue; }
    h2 { color: yellow; }
    (a) blue (b) white (c) yellow (d) red
  10. 10.⚖️ What colour is the text of this element?
    <h2 class="note" id="logo">Hi</h2>
    CSS:
    h2 { color: orange; }
    .note { color: red; }
    #logo { color: purple; }
    (a) red (b) purple (c) yellow (d) orange
  11. 11.⚖️ What colour is the text of this element?
    <p class="note" id="top">Hi</p>
    CSS:
    .note { color: blue; }
    p { color: yellow; }
    (a) green (b) yellow (c) black (d) blue
  12. 12.⚖️ What colour is the text of this element?
    <p class="star" id="intro">Hi</p>
    CSS:
    p { color: purple; }
    .star { color: orange; }
    (a) purple (b) orange (c) red (d) blue
  13. 13.⚖️ What colour is the text of this element?
    <p class="note" id="hero">Hi</p>
    CSS:
    .note { color: white; }
    #hero { color: black; }
    p { color: red; }
    (a) red (b) black (c) green (d) white
  14. 14.⚖️ What colour is the text of this element?
    <p class="note" id="hero">Hi</p>
    CSS:
    p { color: black; }
    p { color: green; }
    (a) red (b) green (c) purple (d) black
  15. 15.⚖️ What colour is the text of this element?
    <p class="box" id="end">Hi</p>
    CSS:
    p { color: purple; }
    p { color: black; }
    (a) black (b) orange (c) blue (d) purple
  16. 16.⚖️ What colour is the text of this element?
    <p class="note" id="intro">Hi</p>
    CSS:
    p { color: red; }
    p { color: green; }
    (a) red (b) blue (c) green (d) white
  17. 17.⚖️ What colour is the text of this element?
    <p class="box" id="main">Hi</p>
    CSS:
    #main { color: white; }
    p { color: green; }
    (a) white (b) black (c) green (d) red
  18. 18.⚖️ What colour is the text of this element?
    <p class="red" id="top">Hi</p>
    CSS:
    p { color: green; }
    p { color: white; }
    (a) white (b) red (c) green (d) orange
  19. 19.⚖️ What colour is the text of this element?
    <h2 class="red" id="top">Hi</h2>
    CSS:
    #top { color: white; }
    #top { color: red; }
    (a) white (b) blue (c) red (d) orange
  20. 20.⚖️ What colour is the text of this element?
    <h2 class="box" id="logo">Hi</h2>
    CSS:
    h2 { color: purple; }
    h2 { color: red; }
    (a) purple (b) orange (c) red (d) yellow
  21. 21.⚖️ What colour is the text of this element?
    <h2 class="big" id="logo">Hi</h2>
    CSS:
    h2 { color: green; }
    #logo { color: red; }
    .big { color: white; }
    (a) red (b) green (c) blue (d) white
  22. 22.⚖️ What colour is the text of this element?
    <h1 class="note" id="main">Hi</h1>
    CSS:
    h1 { color: blue; }
    h1 { color: black; }
    (a) blue (b) black (c) green (d) purple
  23. 23.⚖️ What colour is the text of this element?
    <p class="box" id="main">Hi</p>
    CSS:
    #main { color: red; }
    p { color: purple; }
    (a) red (b) green (c) purple (d) yellow
  24. 24.⚖️ What colour is the text of this element?
    <h2 class="big" id="main">Hi</h2>
    CSS:
    h2 { color: black; }
    #main { color: purple; }
    (a) white (b) black (c) purple (d) red
  25. 25.⚖️ What colour is the text of this element?
    <h2 class="big" id="logo">Hi</h2>
    CSS:
    #logo { color: green; }
    #logo { color: blue; }
    (a) black (b) green (c) purple (d) blue
  26. 26.⚖️ What colour is the text of this element?
    <p class="box" id="main">Hi</p>
    CSS:
    p { color: green; }
    p { color: yellow; }
    (a) yellow (b) purple (c) green (d) red
  27. 27.⚖️ What colour is the text of this element?
    <p class="note" id="hero">Hi</p>
    CSS:
    #hero { color: yellow; }
    .note { color: orange; }
    (a) orange (b) green (c) yellow (d) red
  28. 28.⚖️ What colour is the text of this element?
    <p class="red" id="main">Hi</p>
    CSS:
    p { color: green; }
    #main { color: orange; }
    (a) white (b) yellow (c) green (d) orange
  29. 29.⚖️ What colour is the text of this element?
    <h1 class="star" id="hero">Hi</h1>
    CSS:
    .star { color: black; }
    #hero { color: purple; }
    (a) blue (b) red (c) purple (d) black
  30. 30.⚖️ What colour is the text of this element?
    <h2 class="big" id="intro">Hi</h2>
    CSS:
    .big { color: white; }
    .big { color: blue; }
    (a) black (b) purple (c) white (d) blue
  31. 31.⚖️ What colour is the text of this element?
    <h2 class="box" id="end">Hi</h2>
    CSS:
    #end { color: purple; }
    #end { color: black; }
    (a) yellow (b) blue (c) black (d) purple
  32. 32.⚖️ What colour is the text of this element?
    <h2 class="note" id="logo">Hi</h2>
    CSS:
    #logo { color: black; }
    .note { color: purple; }
    (a) green (b) yellow (c) black (d) purple
  33. 33.⚖️ What colour is the text of this element?
    <h2 class="menu" id="intro">Hi</h2>
    CSS:
    h2 { color: red; }
    h2 { color: yellow; }
    (a) red (b) blue (c) yellow (d) green
  34. 34.⚖️ What colour is the text of this element?
    <h2 class="note" id="hero">Hi</h2>
    CSS:
    .note { color: red; }
    .note { color: white; }
    (a) black (b) red (c) orange (d) white
  35. 35.⚖️ What colour is the text of this element?
    <p class="star" id="top">Hi</p>
    CSS:
    .star { color: purple; }
    #top { color: blue; }
    (a) purple (b) yellow (c) orange (d) blue
  36. 36.⚖️ What colour is the text of this element?
    <p class="box" id="intro">Hi</p>
    CSS:
    p { color: purple; }
    .box { color: red; }
    #intro { color: black; }
    (a) orange (b) black (c) purple (d) red
  37. 37.⚖️ What colour is the text of this element?
    <p class="menu" id="intro">Hi</p>
    CSS:
    p { color: yellow; }
    .menu { color: red; }
    #intro { color: purple; }
    (a) red (b) purple (c) green (d) yellow
  38. 38.⚖️ What colour is the text of this element?
    <p class="red" id="end">Hi</p>
    CSS:
    p { color: black; }
    #end { color: red; }
    .red { color: orange; }
    (a) black (b) orange (c) red (d) purple
  39. 39.⚖️ What colour is the text of this element?
    <h2 class="star" id="end">Hi</h2>
    CSS:
    h2 { color: black; }
    h2 { color: yellow; }
    (a) yellow (b) orange (c) white (d) black
  40. 40.⚖️ What colour is the text of this element?
    <h1 class="big" id="hero">Hi</h1>
    CSS:
    .big { color: purple; }
    #hero { color: blue; }
    (a) purple (b) orange (c) blue (d) yellow

Answer key

  1. the later one
  2. an element selector
  3. yellow
  4. yellow
  5. white
  6. blue
  7. an id selector
  8. white
  9. yellow
  10. purple
  11. blue
  12. orange
  13. black
  14. green
  15. black
  16. green
  17. white
  18. white
  19. red
  20. red
  21. red
  22. black
  23. red
  24. purple
  25. blue
  26. yellow
  27. yellow
  28. orange
  29. purple
  30. blue
  31. black
  32. black
  33. yellow
  34. white
  35. blue
  36. black
  37. purple
  38. red
  39. yellow
  40. blue

Free html and css lessons, practice and worksheets at talentjr.in/html-css-for-kids