← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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