← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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