← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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