← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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