← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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