← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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