← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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