← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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