← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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