← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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