← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 140 · 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.🌈 In #710000 the red part is the hex number 71. What is it as a normal number?
  2. 2.🎯 Which CSS selector matches this element?
    <p class="menu" id="top">Hello</p>
    (a) h1 (b) #intro (c) #menu (d) .menu
  3. 3.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 220px;
      justify-content: center;
    }
    Inside are 2 boxes, each 60px wide (no margins).
  4. 4.📦 How much space top to bottom (px) does this box take in all, margin included?
    .box {
      height: 180px;
      padding: 15px;
      border: 5px solid black;
      margin: 15px;
    }
  5. 5.True or false: #main is an element selector. (a) False (b) True
  6. 6.True or false: JavaScript changes the text size. (a) True (b) False
  7. 7.🖌️ What colour are the letters?
    p {
      font-size: 28px;
      color: green;
      text-align: left;
      background-color: red;
    }
    (a) red (b) green (c) black
  8. 8.🎯 Which CSS selector matches this element?
    <p class="note" id="main">Hello</p>
    (a) .main (b) h1 (c) #note (d) #main
  9. 9.📱 What does a media query check? (a) the battery level (b) the page title (c) the screen width (d) the time of day
  10. 10.✍️ In color: blue; which part is the property? (a) ; (b) : (c) color (d) blue
  11. 11.🔍 Which is the odd one out? (a) adds space around boxes (b) shows a pop-up message (c) changes the page live (d) reacts to a button click
  12. 12.🖌️ Which CSS property centres a heading? (a) text-align (b) font-weight (c) color (d) font-family
  13. 13.📱 Responsive design means a page ___. (a) fits every screen (b) never changes (c) has no pictures (d) is only for laptops
  14. 14.🎯 Which element does the selector .note style? (a) <h2 id="note"> (b) <h2 class="note"> (c) <li class="red"> (d) <h2 class="big">
  15. 15.🖌️ How big is the text, in px?
    h2 {
      font-size: 36px;
      background-color: purple;
      color: green;
      text-align: left;
    }
  16. 16.🧩 Which language lays out the page? (a) CSS (b) JavaScript (c) HTML
  17. 17.True or false: .star is a class selector. (a) True (b) False
  18. 18.✍️ What value is given to text-align in this rule?
    #top {
      font-style: italic;
      width: 300px;
      font-size: 20px;
      text-align: center;
    }
    (a) text-align (b) yellow (c) 10px (d) center
  19. 19.✍️ What value is given to font-weight in this rule?
    h2 {
      font-size: 20px;
      font-style: italic;
      text-align: center;
      font-weight: bold;
    }
    (a) font-weight (b) bold (c) 300px (d) 2px solid
  20. 20.⚖️ What colour is the text of this element?
    <p class="star" id="logo">Hi</p>
    CSS:
    .star { color: white; }
    p { color: orange; }
    #logo { color: black; }
    (a) white (b) black (c) orange (d) blue
  21. 21.🧩 Which language puts a picture on a page? (a) HTML (b) CSS (c) JavaScript
  22. 22.✍️ Which property is set to 300px in this rule?
    li {
      width: 300px;
      font-weight: bold;
    }
    (a) 300px (b) font-style (c) color (d) width
  23. 23.💪 How much empty space (px) is left after the last box?
    .row {
      display: flex;
      width: 240px;
      justify-content: flex-start;
    }
    Inside are 2 boxes, each 100px wide (no margins).
  24. 24.📦 How much space across (px) does this box take in all, margin included?
    .box {
      width: 300px;
      padding: 20px;
      border: 4px solid black;
      margin: 20px;
    }
  25. 25.🎯 Which CSS selector matches this element?
    <span class="star" id="top">Hello</span>
    (a) #intro (b) #star (c) .menu (d) .star
  26. 26.🔍 Which is the odd one out? (a) checks a quiz answer (b) shows a pop-up message (c) sets colours and fonts (d) changes the page live
  27. 27.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the shorter one (b) the later one (c) neither (d) the first one
  28. 28.✍️ What value is given to margin in this rule?
    #top {
      font-style: italic;
      text-align: center;
      margin: 10px;
    }
    (a) 8px (b) bold (c) 10px (d) margin
  29. 29.📦 In the box model, which part is the gap to other boxes? (a) content (b) border (c) margin (d) padding
  30. 30.🔍 Which is the odd one out? (a) makes a form box (b) puts a picture on a page (c) gives the page structure (d) lays out the page
  31. 31.📦 In the box model, which part is a solid or dotted edge? (a) padding (b) margin (c) border (d) content
  32. 32.✍️ How many declarations (property: value pairs) are in this rule?
    p {
      background-color: yellow;
    }
  33. 33.💪 Which flexbox property sets space between boxes? (a) justify-content (b) display: flex (c) align-items (d) gap
  34. 34.📱 The screen is 375px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 20px;
    }
    @media (min-width: 480px) {
      p {
        font-size: 22px;
      }
    }
  35. 35.📱 min-width: 800px applies when the screen is ___. (a) turned off (b) 800px or wider (c) 800px or narrower (d) exactly 100px
  36. 36.What does text-align do? (a) makes the text bold (b) picks the font style (c) centres a heading (d) makes letters bigger
  37. 37.🌈 Which colour is rgb(255, 0, 255)? (a) yellow (b) magenta (c) red (d) black
  38. 38.✍️ Which property is set to 2px solid in this rule?
    p {
      background-color: yellow;
      color: red;
      border: 2px solid;
    }
    (a) width (b) font-style (c) 2px solid (d) border
  39. 39.💪 How much empty space (px) is left after the last box?
    .row {
      display: flex;
      width: 130px;
      justify-content: flex-start;
    }
    Inside are 3 boxes, each 40px wide (no margins).
  40. 40.🎯 What kind of selector is #main? (a) an id selector (b) an element selector (c) a class selector

Answer key

  1. 113
  2. .menu
  3. 50
  4. 250
  5. False
  6. False
  7. green
  8. #main
  9. the screen width
  10. color
  11. adds space around boxes
  12. text-align
  13. fits every screen
  14. <h2 class="note">
  15. 36
  16. CSS
  17. True
  18. center
  19. bold
  20. black
  21. HTML
  22. width
  23. 40
  24. 388
  25. .star
  26. sets colours and fonts
  27. the later one
  28. 10px
  29. margin
  30. lays out the page
  31. border
  32. 1
  33. gap
  34. 20
  35. 800px or wider
  36. centres a heading
  37. magenta
  38. border
  39. 10
  40. an id selector

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