← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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