← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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