← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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