← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 72 · 40 questions
TalentJR

Code tip (Rule, then maths): Find the topic: syntax, selectors, properties, colours, box model, cascade, flexbox or media queries. Decide which rule or property applies to the element. For sizes, write the sum down: both sides for the box model, free space for flexbox.

NameDateTime takenScore ___ / 40
  1. 1.🎯 Which CSS selector matches this element?
    <h1 class="red" id="intro">Hello</h1>
    (a) .intro (b) .box (c) #intro (d) h2
  2. 2.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 280px;
      justify-content: flex-end;
    }
    Inside are 4 boxes, each 60px wide (no margins).
  3. 3.🔍 Which is the odd one out? (a) makes a link (b) reacts to a button click (c) makes a form box (d) gives the page structure
  4. 4.✍️ CSS declarations go inside which brackets? (a) < > (b) [ ] (c) ( ) (d) { }
  5. 5.📦 How much space across (px) does this box take in all, margin included?
    .box {
      width: 60px;
      padding: 10px;
      border: 5px solid black;
      margin: 0px;
    }
  6. 6.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 220px;
      justify-content: flex-end;
    }
    Inside are 4 boxes, each 50px wide (no margins).
  7. 7.📦 How much space across (px) does this box take in all, margin included?
    .box {
      width: 210px;
      padding: 5px;
      border: 3px solid black;
      margin: 10px;
    }
  8. 8.⚖️ What colour is the text of this element?
    <p class="red" id="main">Hi</p>
    CSS:
    .red { color: blue; }
    .red { color: green; }
    (a) blue (b) green (c) purple (d) white
  9. 9.🎯 Which CSS selector matches this element?
    <li class="menu" id="hero">Hello</li>
    (a) .menu (b) #menu (c) #top (d) .hero
  10. 10.📱 The screen is 375px wide. Does the rule inside @media apply?
    p {
      font-size: 16px;
    }
    @media (min-width: 600px) {
      p {
        font-size: 22px;
      }
    }
    (a) Yes (b) No
  11. 11.🖌️ Which CSS property picks the font style? (a) color (b) font-family (c) background-color (d) text-align
  12. 12.💪 How wide (px) is each gap between two boxes?
    .row {
      display: flex;
      width: 300px;
      justify-content: space-between;
    }
    Inside are 3 boxes, each 80px wide (no margins).
  13. 13.📦 How much space top to bottom (px) does this box take in all, margin included?
    .box {
      height: 60px;
      padding: 10px;
      border: 3px solid black;
      margin: 20px;
    }
  14. 14.🌈 Which colour of light is strongest in rgb(39, 196, 113)? (a) green (b) red (c) blue
  15. 15.📱 The screen is 540px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 20px;
    }
    @media (max-width: 480px) {
      p {
        font-size: 16px;
      }
    }
  16. 16.Which of these is the border? (a) the gap to other boxes (b) space inside the border (c) space outside the border (d) a solid or dotted edge
  17. 17.✍️ How many declarations (property: value pairs) are in this rule?
    h2 {
      background-color: yellow;
      padding: 8px;
    }
  18. 18.⚖️ What colour is the text of this element?
    <p class="red" id="main">Hi</p>
    CSS:
    .red { color: purple; }
    .red { color: orange; }
    (a) red (b) purple (c) black (d) orange
  19. 19.🎨 What does CSS stand for? (a) Computer Style Sheets (b) Cascading Style Sheets (c) Colourful Site Styles (d) Creative Sheet System
  20. 20.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
    .box {
      width: 180px;
      padding: 25px;
      border: 3px solid black;
      margin: 20px;
    }
  21. 21.🎨 Which tag holds CSS inside the head? (a) <script> (b) <body> (c) <style> (d) <css>
  22. 22.✍️ What is the selector in this CSS rule?
    .box {
      font-style: italic;
      width: 300px;
    }
    (a) 300px (b) .box (c) h2 (d) font-style
  23. 23.📱 The screen is 700px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 20px;
    }
    @media (max-width: 480px) {
      p {
        font-size: 16px;
      }
    }
  24. 24.🖌️ What colour are the letters?
    li {
      background-color: blue;
      text-align: left;
      font-size: 40px;
      color: red;
    }
    (a) blue (b) red (c) black
  25. 25.🖌️ How big is the text, in px?
    p {
      font-size: 32px;
      color: purple;
      background-color: yellow;
      text-align: left;
    }
  26. 26.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 180px;
      justify-content: flex-end;
    }
    Inside are 3 boxes, each 40px wide (no margins).
  27. 27.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
    .box {
      width: 150px;
      padding: 15px;
      border: 2px solid black;
      margin: 15px;
    }
  28. 28.🎨 Which tag connects an outside CSS file? (a) <css> (b) <a> (c) <img> (d) <link>
  29. 29.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the shorter one (b) the later one (c) the first one (d) neither
  30. 30.🌈 Which colour is rgb(0, 255, 255)? (a) red (b) magenta (c) bright green (d) cyan
  31. 31.📱 The screen is 540px wide. Does the rule inside @media apply?
    p {
      font-size: 16px;
    }
    @media (max-width: 1024px) {
      p {
        font-size: 10px;
      }
    }
    (a) Yes (b) No
  32. 32.📦 How much space across (px) does this box take in all, margin included?
    .box {
      width: 240px;
      padding: 10px;
      border: 3px solid black;
      margin: 15px;
    }
  33. 33.🌈 Which colour is #00ffff? (a) cyan (b) yellow (c) red (d) bright green
  34. 34.🎯 Which element does the selector .red style? (a) <div id="red"> (b) <div class="box"> (c) <span class="star"> (d) <div class="red">
  35. 35.🎯 Which CSS selector matches this element?
    <p class="big" id="intro">Hello</p>
    (a) .red (b) #intro (c) #big (d) #main
  36. 36.What does font-weight do? (a) makes letters bigger (b) colours behind the text (c) picks the font style (d) makes the text bold
  37. 37.True or false: .star is an element selector. (a) True (b) False
  38. 38.⚖️ What colour is the text of this element?
    <h2 class="big" id="logo">Hi</h2>
    CSS:
    .big { color: blue; }
    #logo { color: orange; }
    (a) black (b) blue (c) orange (d) purple
  39. 39.✍️ How many declarations (property: value pairs) are in this rule?
    h2 {
      font-style: italic;
      font-weight: bold;
      margin: 10px;
    }
  40. 40.🎯 Which CSS selector matches this element?
    <div class="big" id="hero">Hello</div>
    (a) .red (b) div (c) .hero (d) #big

Answer key

  1. #intro
  2. 40
  3. reacts to a button click
  4. { }
  5. 90
  6. 20
  7. 246
  8. green
  9. .menu
  10. No
  11. font-family
  12. 30
  13. 126
  14. green
  15. 20
  16. a solid or dotted edge
  17. 2
  18. orange
  19. Cascading Style Sheets
  20. 236
  21. <style>
  22. .box
  23. 20
  24. red
  25. 32
  26. 60
  27. 184
  28. <link>
  29. the later one
  30. cyan
  31. Yes
  32. 296
  33. cyan
  34. <div class="red">
  35. #intro
  36. makes the text bold
  37. False
  38. orange
  39. 3
  40. div

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