← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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