← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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