← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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