← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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