← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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