← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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