← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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