← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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