← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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