← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 29 · 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.⚖️ Which selector is the strongest? (a) an id selector (b) a class selector (c) an element selector
  2. 2.🖌️ How big is the text, in px?
    h1 {
      color: yellow;
      font-size: 24px;
      text-align: center;
      background-color: black;
    }
  3. 3.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
    .box {
      width: 140px;
      padding: 15px;
      border: 1px solid black;
      margin: 20px;
    }
  4. 4.📱 The screen is 1100px wide. Does the rule inside @media apply?
    p {
      font-size: 12px;
    }
    @media (max-width: 1024px) {
      p {
        font-size: 10px;
      }
    }
    (a) Yes (b) No
  5. 5.📱 The screen is 1366px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 20px;
    }
    @media (max-width: 1024px) {
      p {
        font-size: 14px;
      }
    }
  6. 6.True or false: JavaScript makes a link. (a) False (b) True
  7. 7.✍️ Which sign ends each CSS declaration? (a) ; (b) . (c) : (d) ,
  8. 8.🎯 Which sign starts an id selector? (a) & (b) # (c) @ (d) .
  9. 9.🖌️ How big is the text, in px?
    p {
      background-color: red;
      color: orange;
      font-size: 36px;
      text-align: left;
    }
  10. 10.Which of these does JavaScript do? (a) sets colours and fonts (b) reacts to a button click (c) changes the text size (d) gives the page structure
  11. 11.✍️ What value is given to width in this rule?
    #top {
      width: 300px;
      padding: 8px;
      font-style: italic;
    }
    (a) width (b) red (c) 300px (d) italic
  12. 12.💪 Which flexbox property lines boxes up across? (a) gap (b) flex-direction (c) align-items (d) justify-content
  13. 13.⚖️ What colour is the text of this element?
    <h2 class="box" id="top">Hi</h2>
    CSS:
    #top { color: black; }
    #top { color: red; }
    (a) blue (b) yellow (c) black (d) red
  14. 14.✍️ What is the selector in this CSS rule?
    h2 {
      text-align: center;
      font-size: 20px;
      width: 300px;
    }
    (a) 20px (b) h1 (c) h2 (d) text-align
  15. 15.📱 What does a media query check? (a) the time of day (b) the page title (c) the battery level (d) the screen width
  16. 16.📱 The screen is 540px wide. Does the rule inside @media apply?
    p {
      font-size: 20px;
    }
    @media (min-width: 1024px) {
      p {
        font-size: 28px;
      }
    }
    (a) Yes (b) No
  17. 17.🎯 Which CSS selector matches this element?
    <h1 class="big" id="logo">Hello</h1>
    (a) #end (b) #big (c) h1 (d) h2
  18. 18.🖌️ What colour are the letters?
    h1 {
      background-color: green;
      color: blue;
      text-align: left;
      font-size: 40px;
    }
    (a) green (b) yellow (c) blue
  19. 19.🖌️ What colour are the letters?
    li {
      background-color: purple;
      text-align: left;
      font-size: 28px;
      color: blue;
    }
    (a) purple (b) black (c) blue
  20. 20.📦 In the box model, which part is the gap round content? (a) margin (b) border (c) padding (d) content
  21. 21.✍️ What is the selector in this CSS rule?
    li {
      color: red;
      border: 2px solid;
    }
    (a) li (b) color (c) 2px solid (d) body
  22. 22.🌈 Which colour of light is strongest in rgb(81, 36, 158)? (a) green (b) blue (c) red
  23. 23.🎯 What kind of selector is #logo? (a) an element selector (b) a class selector (c) an id selector
  24. 24.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
    .box {
      width: 200px;
      padding: 15px;
      border: 4px solid black;
      margin: 5px;
    }
  25. 25.🔍 Which is the odd one out? (a) makes a form box (b) sets colours and fonts (c) makes headings and lists (d) gives the page structure
  26. 26.Which of these does CSS do? (a) counts down a timer (b) makes headings and lists (c) puts a picture on a page (d) sets colours and fonts
  27. 27.✍️ How does a CSS comment start? (a) # (b) /* (c) // (d) <!--
  28. 28.📱 The screen is 820px wide. Does the rule inside @media apply?
    p {
      font-size: 24px;
    }
    @media (max-width: 480px) {
      p {
        font-size: 20px;
      }
    }
    (a) No (b) Yes
  29. 29.✍️ In color: blue; which part is the value? (a) blue (b) ; (c) : (d) color
  30. 30.🎨 Which tag holds CSS inside the head? (a) <css> (b) <style> (c) <body> (d) <script>
  31. 31.🎯 Which CSS selector matches this element?
    <h2 class="star" id="main">Hello</h2>
    (a) li (b) #star (c) #main (d) .menu
  32. 32.💪 How wide (px) is each gap between two boxes?
    .row {
      display: flex;
      width: 320px;
      justify-content: space-between;
    }
    Inside are 3 boxes, each 80px wide (no margins).
  33. 33.🧩 Which language puts a picture on a page? (a) JavaScript (b) HTML (c) CSS
  34. 34.✍️ How many declarations (property: value pairs) are in this rule?
    .box {
      padding: 8px;
      text-align: center;
      width: 300px;
    }
  35. 35.🧩 Which language gives the page structure? (a) JavaScript (b) CSS (c) HTML
  36. 36.📱 Responsive design means a page ___. (a) fits every screen (b) is only for laptops (c) never changes (d) has no pictures
  37. 37.🖌️ Which CSS property colours behind the text? (a) font-size (b) text-align (c) font-weight (d) background-color
  38. 38.🖌️ Which CSS property makes letters bigger? (a) color (b) text-align (c) font-family (d) font-size
  39. 39.✍️ What value is given to padding in this rule?
    h2 {
      color: red;
      margin: 10px;
      padding: 8px;
      font-style: italic;
    }
    (a) bold (b) 8px (c) 2px solid (d) padding
  40. 40.📦 How much space top to bottom (px) does this box take in all, margin included?
    .box {
      height: 60px;
      padding: 5px;
      border: 3px solid black;
      margin: 10px;
    }

Answer key

  1. an id selector
  2. 24
  3. 172
  4. No
  5. 20
  6. False
  7. ;
  8. #
  9. 36
  10. reacts to a button click
  11. 300px
  12. align-items
  13. red
  14. h2
  15. the screen width
  16. No
  17. h1
  18. blue
  19. blue
  20. padding
  21. li
  22. blue
  23. an id selector
  24. 238
  25. sets colours and fonts
  26. sets colours and fonts
  27. /*
  28. No
  29. blue
  30. <style>
  31. #main
  32. 40
  33. HTML
  34. 3
  35. HTML
  36. fits every screen
  37. background-color
  38. font-size
  39. 8px
  40. 96

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