← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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