← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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