← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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