← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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