← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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