← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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