← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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