← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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