← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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