← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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