← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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