← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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