← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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