← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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