← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 740 · 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.🖌️ How big is the text, in px?
    h2 {
      text-align: center;
      background-color: white;
      font-size: 28px;
      color: purple;
    }
  2. 2.✍️ What is the selector in this CSS rule?
    h1 {
      border: 2px solid;
      font-size: 20px;
      font-weight: bold;
      text-align: center;
    }
    (a) 20px (b) p (c) border (d) h1
  3. 3.✍️ What value is given to font-weight in this rule?
    h1 {
      font-weight: bold;
      color: red;
    }
    (a) font-weight (b) 300px (c) 2px solid (d) bold
  4. 4.🧩 Which language rounds box corners? (a) JavaScript (b) HTML (c) CSS
  5. 5.✍️ CSS declarations go inside which brackets? (a) { } (b) [ ] (c) < > (d) ( )
  6. 6.🔍 Which is the odd one out? (a) makes a form box (b) makes headings and lists (c) changes the text size (d) puts a picture on a page
  7. 7.🎯 Can many elements share the same class? (a) No (b) Yes
  8. 8.⚖️ What colour is the text of this element?
    <h1 class="menu" id="intro">Hi</h1>
    CSS:
    h1 { color: green; }
    #intro { color: orange; }
    .menu { color: red; }
    (a) purple (b) orange (c) red (d) green
  9. 9.🌈 How many pairs of hex digits are in a colour like #ff8800? (a) 6 (b) 3 (c) 4 (d) 2
  10. 10.What does background-color do? (a) sets the letter colour (b) picks the font style (c) colours behind the text (d) makes letters bigger
  11. 11.🌈 Which hex code is blue? (a) #ffff00 (b) #0000ff (c) #ff0000 (d) #00ffff
  12. 12.✍️ What value is given to margin in this rule?
    #top {
      background-color: yellow;
      margin: 10px;
      text-align: center;
    }
    (a) 8px (b) bold (c) 10px (d) margin
  13. 13.📱 The screen is 1366px wide. Does the rule inside @media apply?
    p {
      font-size: 20px;
    }
    @media (max-width: 600px) {
      p {
        font-size: 18px;
      }
    }
    (a) Yes (b) No
  14. 14.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 180px;
      justify-content: flex-end;
    }
    Inside are 3 boxes, each 50px wide (no margins).
  15. 15.📱 The screen is 375px wide. Does the rule inside @media apply?
    p {
      font-size: 16px;
    }
    @media (min-width: 480px) {
      p {
        font-size: 24px;
      }
    }
    (a) No (b) Yes
  16. 16.🖌️ Where does the text sit on its line?
    h1 {
      background-color: white;
      text-align: center;
      font-size: 12px;
      color: red;
    }
    (a) on the left (b) on the right (c) in the middle
  17. 17.📱 The screen is 700px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 12px;
    }
    @media (max-width: 600px) {
      p {
        font-size: 10px;
      }
    }
  18. 18.🌈 Which hex code is red? (a) #000000 (b) #ff0000 (c) #ffffff (d) #ffff00
  19. 19.✍️ How many declarations (property: value pairs) are in this rule?
    p {
      color: red;
      font-style: italic;
      width: 300px;
      background-color: yellow;
    }
  20. 20.True or false: the border is a solid or dotted edge. (a) False (b) True
  21. 21.✍️ Which sign ends each CSS declaration? (a) , (b) : (c) . (d) ;
  22. 22.📦 How much space across (px) does this box take in all, margin included?
    .box {
      width: 280px;
      padding: 5px;
      border: 2px solid black;
      margin: 10px;
    }
  23. 23.🎯 Which element does the selector .red style? (a) <div id="red"> (b) <div class="box"> (c) <span class="star"> (d) <div class="red">
  24. 24.📱 max-width: 600px applies when the screen is ___. (a) turned off (b) 600px or wider (c) exactly 1000px (d) 600px or narrower
  25. 25.📦 How much space top to bottom (px) does this box take in all, margin included?
    .box {
      height: 200px;
      padding: 10px;
      border: 2px solid black;
      margin: 20px;
    }
  26. 26.⚖️ What colour is the text of this element?
    <h1 class="menu" id="intro">Hi</h1>
    CSS:
    h1 { color: orange; }
    h1 { color: white; }
    (a) yellow (b) orange (c) white (d) black
  27. 27.Which of these does CSS do? (a) reacts to a button click (b) checks a quiz answer (c) adds space around boxes (d) shows a pop-up message
  28. 28.Which of these does CSS do? (a) makes headings and lists (b) shows a pop-up message (c) makes a form box (d) changes the text size
  29. 29.✍️ Which sign goes between a property and its value? (a) : (b) ; (c) = (d) -
  30. 30.🧩 Which language shows a pop-up message? (a) JavaScript (b) HTML (c) CSS
  31. 31.⚖️ What colour is the text of this element?
    <p class="star" id="hero">Hi</p>
    CSS:
    .star { color: orange; }
    .star { color: blue; }
    (a) red (b) blue (c) orange (d) purple
  32. 32.🎯 Which CSS selector matches this element?
    <li class="star" id="main">Hello</li>
    (a) div (b) li (c) .menu (d) #logo
  33. 33.🎯 What kind of selector is #top? (a) a class selector (b) an id selector (c) an element selector
  34. 34.📱 The screen is 320px wide. Does the rule inside @media apply?
    p {
      font-size: 20px;
    }
    @media (min-width: 600px) {
      p {
        font-size: 26px;
      }
    }
    (a) Yes (b) No
  35. 35.✍️ What value is given to font-style in this rule?
    h2 {
      font-style: italic;
      width: 300px;
      margin: 10px;
    }
    (a) font-style (b) italic (c) red (d) 20px
  36. 36.⚖️ Which selector is the weakest? (a) an id selector (b) an element selector (c) a class selector
  37. 37.💪 How much empty space (px) is left after the last box?
    .row {
      display: flex;
      width: 320px;
      justify-content: flex-start;
    }
    Inside are 3 boxes, each 80px wide (no margins).
  38. 38.True or false: margin is the gap to other boxes. (a) True (b) False
  39. 39.✍️ What value is given to padding in this rule?
    h1 {
      padding: 8px;
      font-style: italic;
      margin: 10px;
    }
    (a) 2px solid (b) bold (c) 8px (d) padding
  40. 40.🎯 What kind of selector is .note? (a) a class selector (b) an id selector (c) an element selector

Answer key

  1. 28
  2. h1
  3. bold
  4. CSS
  5. { }
  6. changes the text size
  7. Yes
  8. orange
  9. 3
  10. colours behind the text
  11. #0000ff
  12. 10px
  13. No
  14. 30
  15. No
  16. in the middle
  17. 12
  18. #ff0000
  19. 4
  20. True
  21. ;
  22. 314
  23. <div class="red">
  24. 600px or narrower
  25. 264
  26. white
  27. adds space around boxes
  28. changes the text size
  29. :
  30. JavaScript
  31. blue
  32. li
  33. an id selector
  34. No
  35. italic
  36. an element selector
  37. 80
  38. True
  39. 8px
  40. a class selector

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