← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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