← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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