← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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