← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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