← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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