← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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