← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 620 · 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 {
      font-size: 20px;
      color: blue;
      text-align: center;
      background-color: green;
    }
  2. 2.✍️ What is the selector in this CSS rule?
    h2 {
      width: 300px;
      color: red;
    }
    (a) red (b) width (c) h1 (d) h2
  3. 3.📱 max-width: 600px applies when the screen is ___. (a) 600px or wider (b) 600px or narrower (c) turned off (d) exactly 1000px
  4. 4.✍️ What value is given to margin in this rule?
    body {
      margin: 10px;
      text-align: center;
      font-style: italic;
    }
    (a) 8px (b) bold (c) margin (d) 10px
  5. 5.What does font-weight do? (a) picks the font style (b) centres a heading (c) makes letters bigger (d) makes the text bold
  6. 6.✍️ What value is given to font-size in this rule?
    #top {
      font-size: 20px;
      color: red;
    }
    (a) center (b) font-size (c) yellow (d) 20px
  7. 7.🌈 Which colour is #00ffff? (a) blue (b) cyan (c) yellow (d) black
  8. 8.🧩 Which language puts a picture on a page? (a) JavaScript (b) CSS (c) HTML
  9. 9.True or false: .big is an element selector. (a) False (b) True
  10. 10.⚖️ Which selector is the strongest? (a) an id selector (b) a class selector (c) an element selector
  11. 11.🌈 Which hex code is blue? (a) #ffffff (b) #0000ff (c) #00ff00 (d) #ffff00
  12. 12.What does justify-content: flex-start do? (a) packs boxes at the end (b) puts boxes in the middle (c) packs boxes at the start (d) equal gaps, none at ends
  13. 13.🎯 Which element does the selector .red style? (a) <p class="red"> (b) <p id="red"> (c) <h1 class="star"> (d) <p class="box">
  14. 14.Which of these does JavaScript do? (a) rounds box corners (b) counts down a timer (c) sets colours and fonts (d) makes a form box
  15. 15.⚖️ What colour is the text of this element?
    <h2 class="box" id="top">Hi</h2>
    CSS:
    h2 { color: black; }
    h2 { color: yellow; }
    (a) black (b) white (c) red (d) yellow
  16. 16.🎯 Which CSS selector matches this element?
    <p class="box" id="hero">Hello</p>
    (a) .hero (b) .box (c) #top (d) h1
  17. 17.📱 Responsive design means a page ___. (a) is only for laptops (b) never changes (c) has no pictures (d) fits every screen
  18. 18.🖌️ Which CSS property makes the text bold? (a) font-size (b) font-weight (c) text-align (d) color
  19. 19.📱 The screen is 820px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 24px;
    }
    @media (max-width: 768px) {
      p {
        font-size: 22px;
      }
    }
  20. 20.📱 The screen is 820px wide. Does the rule inside @media apply?
    p {
      font-size: 20px;
    }
    @media (max-width: 600px) {
      p {
        font-size: 18px;
      }
    }
    (a) No (b) Yes
  21. 21.✍️ How many declarations (property: value pairs) are in this rule?
    .note {
      padding: 8px;
      border: 2px solid;
    }
  22. 22.🌈 Hex digits go 0 to 9, then A to which letter? (a) F (b) G (c) J (d) Z
  23. 23.✍️ What value is given to text-align in this rule?
    .box {
      font-weight: bold;
      text-align: center;
    }
    (a) yellow (b) center (c) text-align (d) 10px
  24. 24.🌈 Which colour of light is strongest in rgb(70, 84, 219)? (a) green (b) blue (c) red
  25. 25.📦 How much space top to bottom (px) does this box take in all, margin included?
    .box {
      height: 120px;
      padding: 5px;
      border: 1px solid black;
      margin: 5px;
    }
  26. 26.✍️ How does a CSS comment start? (a) <!-- (b) // (c) # (d) /*
  27. 27.Which of these does JavaScript do? (a) changes the text size (b) gives the page structure (c) puts a picture on a page (d) reacts to a button click
  28. 28.📦 How much space across (px) does this box take in all, margin included?
    .box {
      width: 60px;
      padding: 20px;
      border: 5px solid black;
      margin: 0px;
    }
  29. 29.📦 How much space across (px) does this box take in all, margin included?
    .box {
      width: 290px;
      padding: 20px;
      border: 4px solid black;
      margin: 5px;
    }
  30. 30.✍️ In color: blue; which part is the value? (a) : (b) ; (c) color (d) blue
  31. 31.📱 The screen is 375px wide. Does the rule inside @media apply?
    p {
      font-size: 12px;
    }
    @media (max-width: 600px) {
      p {
        font-size: 8px;
      }
    }
    (a) Yes (b) No
  32. 32.What does color do? (a) makes letters bigger (b) centres a heading (c) colours behind the text (d) sets the letter colour
  33. 33.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 440px;
      justify-content: center;
    }
    Inside are 4 boxes, each 100px wide (no margins).
  34. 34.📦 How much space across (px) does this box take in all, margin included?
    .box {
      width: 280px;
      padding: 20px;
      border: 4px solid black;
      margin: 20px;
    }
  35. 35.🖌️ Where does the text sit on its line?
    h1 {
      background-color: yellow;
      color: orange;
      font-size: 40px;
      text-align: right;
    }
    (a) on the right (b) in the middle (c) on the left
  36. 36.✍️ Which property is set to italic in this rule?
    body {
      font-size: 20px;
      font-style: italic;
      text-align: center;
    }
    (a) font-size (b) color (c) italic (d) font-style
  37. 37.📦 How much space across (px) does this box take in all, margin included?
    .box {
      width: 130px;
      padding: 25px;
      border: 5px solid black;
      margin: 15px;
    }
  38. 38.🎯 Which CSS selector matches this element?
    <span class="menu" id="end">Hello</span>
    (a) #hero (b) .menu (c) .end (d) #menu
  39. 39.⚖️ What colour is the text of this element?
    <h1 class="menu" id="hero">Hi</h1>
    CSS:
    #hero { color: red; }
    .menu { color: black; }
    (a) blue (b) white (c) black (d) red
  40. 40.📱 min-width: 800px applies when the screen is ___. (a) 800px or narrower (b) exactly 100px (c) 800px or wider (d) turned off

Answer key

  1. 20
  2. h2
  3. 600px or narrower
  4. 10px
  5. makes the text bold
  6. 20px
  7. cyan
  8. HTML
  9. False
  10. an id selector
  11. #0000ff
  12. packs boxes at the start
  13. <p class="red">
  14. counts down a timer
  15. yellow
  16. .box
  17. fits every screen
  18. font-weight
  19. 24
  20. No
  21. 2
  22. F
  23. center
  24. blue
  25. 142
  26. /*
  27. reacts to a button click
  28. 110
  29. 348
  30. blue
  31. Yes
  32. sets the letter colour
  33. 20
  34. 368
  35. on the right
  36. font-style
  37. 220
  38. .menu
  39. red
  40. 800px or wider

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