← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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