← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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