← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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