← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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