← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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