← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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