← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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