← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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