← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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