← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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