← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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