← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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