← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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