← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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