← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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