← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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