← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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