← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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