← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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