← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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