← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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