← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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