← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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