← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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