← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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