← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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