← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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