← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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