← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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