← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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