← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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