← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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