← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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