← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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