← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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