← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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