← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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