← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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