← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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