← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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