← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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