← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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