← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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