← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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