← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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