← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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