← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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