← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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