← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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