← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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