← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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