← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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