← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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