← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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