← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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