← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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