← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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