← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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