← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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