← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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