← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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