← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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