← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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