← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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