← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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