← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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