← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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