← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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