← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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