← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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