← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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