← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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