← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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