← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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