← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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