← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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