← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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