← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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