← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 81 · 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.📱 The screen is 1100px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 16px;
    }
    @media (min-width: 480px) {
      p {
        font-size: 18px;
      }
    }
  2. 2.🖌️ What colour is behind the letters?
    li {
      font-size: 32px;
      color: white;
      background-color: black;
      text-align: right;
    }
    (a) white (b) black (c) purple
  3. 3.What does justify-content: space-between do? (a) packs boxes at the end (b) puts boxes in the middle (c) equal gaps, none at ends (d) packs boxes at the start
  4. 4.🧩 Which language adds space around boxes? (a) JavaScript (b) HTML (c) CSS
  5. 5.🔍 Which is the odd one out? (a) checks a quiz answer (b) shows a pop-up message (c) puts a picture on a page (d) changes the page live
  6. 6.⚖️ Which selector is the strongest? (a) a class selector (b) an id selector (c) an element selector
  7. 7.⚖️ What colour is the text of this element?
    <h2 class="big" id="top">Hi</h2>
    CSS:
    #top { color: yellow; }
    h2 { color: white; }
    .big { color: orange; }
    (a) orange (b) blue (c) yellow (d) white
  8. 8.📦 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: 5px;
      border: 1px solid black;
      margin: 0px;
    }
  9. 9.📱 What does a media query check? (a) the screen width (b) the battery level (c) the page title (d) the time of day
  10. 10.🎯 Which CSS selector matches this element?
    <p class="menu" id="end">Hello</p>
    (a) #menu (b) .note (c) #end (d) #hero
  11. 11.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 180px;
      justify-content: flex-end;
    }
    Inside are 4 boxes, each 40px wide (no margins).
  12. 12.📱 The screen is 1100px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 24px;
    }
    @media (max-width: 600px) {
      p {
        font-size: 18px;
      }
    }
  13. 13.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 200px;
      justify-content: flex-end;
    }
    Inside are 4 boxes, each 40px wide (no margins).
  14. 14.📱 The screen is 820px wide. Does the rule inside @media apply?
    p {
      font-size: 24px;
    }
    @media (min-width: 1024px) {
      p {
        font-size: 30px;
      }
    }
    (a) Yes (b) No
  15. 15.⚖️ What colour is the text of this element?
    <h2 class="menu" id="intro">Hi</h2>
    CSS:
    .menu { color: red; }
    .menu { color: yellow; }
    (a) red (b) black (c) green (d) yellow
  16. 16.✍️ How does a CSS comment start? (a) <!-- (b) /* (c) # (d) //
  17. 17.📱 The screen is 700px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 16px;
    }
    @media (min-width: 600px) {
      p {
        font-size: 24px;
      }
    }
  18. 18.🎯 What kind of selector is #main? (a) an id selector (b) a class selector (c) an element selector
  19. 19.✍️ Which sign ends each CSS declaration? (a) : (b) , (c) . (d) ;
  20. 20.⚖️ What colour is the text of this element?
    <p class="star" id="logo">Hi</p>
    CSS:
    #logo { color: green; }
    p { color: purple; }
    (a) white (b) black (c) purple (d) green
  21. 21.🔍 Which is the odd one out? (a) counts down a timer (b) lays out the page (c) adds space around boxes (d) rounds box corners
  22. 22.✍️ What value is given to padding in this rule?
    li {
      color: red;
      padding: 8px;
      text-align: center;
      font-weight: bold;
    }
    (a) bold (b) padding (c) 2px solid (d) 8px
  23. 23.🎯 Which CSS selector matches this element?
    <p class="red" id="intro">Hello</p>
    (a) #red (b) h1 (c) .intro (d) .red
  24. 24.📦 How much space across (px) does this box take in all, margin included?
    .box {
      width: 70px;
      padding: 20px;
      border: 5px solid black;
      margin: 10px;
    }
  25. 25.True or false: HTML makes a form box. (a) False (b) True
  26. 26.🌈 Which hex code is bright green? (a) #ffff00 (b) #ff00ff (c) #00ffff (d) #00ff00
  27. 27.💪 Which flexbox property lines boxes up across? (a) display: flex (b) flex-direction (c) align-items (d) justify-content
  28. 28.🧩 Which language shows a pop-up message? (a) HTML (b) JavaScript (c) CSS
  29. 29.📱 The screen is 540px wide. Does the rule inside @media apply?
    p {
      font-size: 12px;
    }
    @media (max-width: 1024px) {
      p {
        font-size: 8px;
      }
    }
    (a) No (b) Yes
  30. 30.🎯 What kind of selector is #hero? (a) an id selector (b) a class selector (c) an element selector
  31. 31.🎨 Which attribute adds CSS inside one tag? (a) src (b) href (c) style (d) alt
  32. 32.🌈 Which hex code is yellow? (a) #ff00ff (b) #ffff00 (c) #0000ff (d) #00ffff
  33. 33.🖌️ What colour are the letters?
    h1 {
      text-align: left;
      font-size: 24px;
      background-color: red;
      color: orange;
    }
    (a) red (b) orange (c) white
  34. 34.✍️ Which property is set to 300px in this rule?
    .box {
      text-align: center;
      color: red;
      width: 300px;
      font-weight: bold;
    }
    (a) color (b) font-style (c) 300px (d) width
  35. 35.True or false: padding is space outside the border. (a) True (b) False
  36. 36.💪 How much empty space (px) is left after the last box?
    .row {
      display: flex;
      width: 170px;
      justify-content: flex-start;
    }
    Inside are 3 boxes, each 40px wide (no margins).
  37. 37.🧩 Which language makes headings and lists? (a) HTML (b) JavaScript (c) CSS
  38. 38.🎯 Which sign starts a class selector? (a) & (b) @ (c) . (d) #
  39. 39.🌈 Which colour is #ffffff? (a) black (b) bright green (c) cyan (d) white
  40. 40.✍️ What value is given to color in this rule?
    p {
      color: red;
      font-style: italic;
      font-weight: bold;
    }
    (a) color (b) center (c) 20px (d) red

Answer key

  1. 18
  2. black
  3. equal gaps, none at ends
  4. CSS
  5. puts a picture on a page
  6. an id selector
  7. yellow
  8. 162
  9. the screen width
  10. #end
  11. 20
  12. 24
  13. 40
  14. No
  15. yellow
  16. /*
  17. 24
  18. an id selector
  19. ;
  20. green
  21. counts down a timer
  22. 8px
  23. .red
  24. 140
  25. True
  26. #00ff00
  27. align-items
  28. JavaScript
  29. Yes
  30. an id selector
  31. style
  32. #ffff00
  33. orange
  34. width
  35. False
  36. 50
  37. HTML
  38. .
  39. white
  40. red

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