← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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