← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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