← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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