← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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