← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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