← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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