← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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