← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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