← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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