← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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