← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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