← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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