← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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