← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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