← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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