← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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