← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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