← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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