← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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