← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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