← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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