← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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