← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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