← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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