← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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