← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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