← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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