← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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