← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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