← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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