← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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