← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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