← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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