← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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