← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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