← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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