← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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