← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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