← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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