← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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