← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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