← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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