← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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