← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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