← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 51 · 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.✍️ What value is given to width in this rule?
    h1 {
      background-color: yellow;
      color: red;
      width: 300px;
    }
    (a) 300px (b) italic (c) red (d) width
  2. 2.⚖️ What colour is the text of this element?
    <h2 class="big" id="top">Hi</h2>
    CSS:
    #top { color: orange; }
    #top { color: purple; }
    (a) black (b) orange (c) purple (d) white
  3. 3.📦 How much space top to bottom (px) does this box take in all, margin included?
    .box {
      height: 50px;
      padding: 10px;
      border: 1px solid black;
      margin: 10px;
    }
  4. 4.🔍 Which is the odd one out? (a) lays out the page (b) puts a picture on a page (c) adds space around boxes (d) changes the text size
  5. 5.📱 The screen is 414px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 20px;
    }
    @media (max-width: 768px) {
      p {
        font-size: 14px;
      }
    }
  6. 6.📱 max-width: 600px applies when the screen is ___. (a) 600px or narrower (b) 600px or wider (c) turned off (d) exactly 1000px
  7. 7.True or false: the content is a solid or dotted edge. (a) True (b) False
  8. 8.🖌️ Which CSS property sets the letter colour? (a) font-family (b) text-align (c) background-color (d) color
  9. 9.✍️ How many declarations (property: value pairs) are in this rule?
    h2 {
      margin: 10px;
      text-align: center;
      padding: 8px;
      background-color: yellow;
    }
  10. 10.📱 The screen is 320px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 20px;
    }
    @media (max-width: 600px) {
      p {
        font-size: 18px;
      }
    }
  11. 11.🌈 In #rrggbb, which colour do the first two digits give? (a) green (b) blue (c) black (d) red
  12. 12.✍️ Which property is set to 300px in this rule?
    h1 {
      border: 2px solid;
      width: 300px;
    }
    (a) font-style (b) 300px (c) color (d) width
  13. 13.🖌️ Where does the text sit on its line?
    h2 {
      color: orange;
      text-align: left;
      font-size: 12px;
      background-color: red;
    }
    (a) on the right (b) in the middle (c) on the left
  14. 14.💪 How wide (px) is each gap between two boxes?
    .row {
      display: flex;
      width: 150px;
      justify-content: space-between;
    }
    Inside are 2 boxes, each 40px wide (no margins).
  15. 15.💪 How wide (px) is each gap between two boxes?
    .row {
      display: flex;
      width: 280px;
      justify-content: space-between;
    }
    Inside are 4 boxes, each 40px wide (no margins).
  16. 16.📱 The screen is 1366px wide. Does the rule inside @media apply?
    p {
      font-size: 20px;
    }
    @media (max-width: 768px) {
      p {
        font-size: 18px;
      }
    }
    (a) Yes (b) No
  17. 17.⚖️ What colour is the text of this element?
    <h1 class="menu" id="logo">Hi</h1>
    CSS:
    h1 { color: red; }
    .menu { color: white; }
    (a) purple (b) red (c) white (d) orange
  18. 18.🎯 What kind of selector is .star? (a) an id selector (b) an element selector (c) a class selector
  19. 19.📱 Responsive design means a page ___. (a) is only for laptops (b) has no pictures (c) never changes (d) fits every screen
  20. 20.🎨 Which attribute adds CSS inside one tag? (a) alt (b) src (c) href (d) style
  21. 21.🎯 What kind of selector is #end? (a) an element selector (b) an id selector (c) a class selector
  22. 22.📱 The screen is 1366px wide. Does the rule inside @media apply?
    p {
      font-size: 20px;
    }
    @media (max-width: 480px) {
      p {
        font-size: 14px;
      }
    }
    (a) No (b) Yes
  23. 23.✍️ Which property is set to red in this rule?
    h1 {
      text-align: center;
      color: red;
      font-style: italic;
      font-weight: bold;
    }
    (a) red (b) text-align (c) font-size (d) color
  24. 24.📱 The screen is 540px wide. Does the rule inside @media apply?
    p {
      font-size: 24px;
    }
    @media (max-width: 600px) {
      p {
        font-size: 18px;
      }
    }
    (a) Yes (b) No
  25. 25.📦 In the box model, which part is the gap round content? (a) padding (b) border (c) margin (d) content
  26. 26.⚖️ Which selector is the weakest? (a) a class selector (b) an element selector (c) an id selector
  27. 27.🖌️ What colour are the letters?
    h1 {
      color: red;
      text-align: left;
      font-size: 12px;
      background-color: purple;
    }
    (a) white (b) red (c) purple
  28. 28.What does background-color do? (a) centres a heading (b) colours behind the text (c) picks the font style (d) sets the letter colour
  29. 29.True or false: padding is space inside the border. (a) False (b) True
  30. 30.🌈 Which colour is #000000? (a) blue (b) yellow (c) black (d) magenta
  31. 31.🎯 What kind of selector is #main? (a) an element selector (b) an id selector (c) a class selector
  32. 32.📱 The screen is 375px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 16px;
    }
    @media (max-width: 600px) {
      p {
        font-size: 10px;
      }
    }
  33. 33.✍️ Which sign goes between a property and its value? (a) = (b) - (c) : (d) ;
  34. 34.📦 In the box model, which part is the line round the box? (a) margin (b) content (c) padding (d) border
  35. 35.🔍 Which is the odd one out? (a) lays out the page (b) makes headings and lists (c) adds space around boxes (d) sets colours and fonts
  36. 36.True or false: HTML makes headings and lists. (a) False (b) True
  37. 37.✍️ What value is given to text-align in this rule?
    .box {
      background-color: yellow;
      color: red;
      text-align: center;
      margin: 10px;
    }
    (a) text-align (b) yellow (c) center (d) 10px
  38. 38.🖌️ How big is the text, in px?
    p {
      font-size: 12px;
      background-color: white;
      text-align: right;
      color: red;
    }
  39. 39.📱 The screen is 375px wide. Does the rule inside @media apply?
    p {
      font-size: 16px;
    }
    @media (min-width: 600px) {
      p {
        font-size: 20px;
      }
    }
    (a) No (b) Yes
  40. 40.📱 What does a media query check? (a) the screen width (b) the time of day (c) the battery level (d) the page title

Answer key

  1. 300px
  2. purple
  3. 92
  4. puts a picture on a page
  5. 14
  6. 600px or narrower
  7. False
  8. color
  9. 4
  10. 18
  11. red
  12. width
  13. on the left
  14. 70
  15. 40
  16. No
  17. white
  18. a class selector
  19. fits every screen
  20. style
  21. an id selector
  22. No
  23. color
  24. Yes
  25. padding
  26. an element selector
  27. red
  28. colours behind the text
  29. True
  30. black
  31. an id selector
  32. 10
  33. :
  34. border
  35. makes headings and lists
  36. True
  37. center
  38. 12
  39. No
  40. the screen width

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