← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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