← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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