← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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