← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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