← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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