← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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