← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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