← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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