← Which CSS rule wins? lesson New set →

CSS Worksheet: Which Rule Wins

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

Answer key

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

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