← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 284 · 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 property is set to 300px in this rule?
    li {
      width: 300px;
      border: 2px solid;
    }
    (a) font-style (b) color (c) width (d) 300px
  2. 2.🎯 Which CSS selector matches this element?
    <li class="big" id="intro">Hello</li>
    (a) #main (b) div (c) .intro (d) li
  3. 3.Which of these is the content? (a) a solid or dotted edge (b) space outside the border (c) space inside the border (d) the text or picture
  4. 4.🖌️ What colour is behind the letters?
    li {
      text-align: left;
      background-color: yellow;
      font-size: 12px;
      color: purple;
    }
    (a) purple (b) red (c) yellow
  5. 5.⚖️ Which selector is the weakest? (a) an id selector (b) an element selector (c) a class selector
  6. 6.🧩 Which language changes the page live? (a) CSS (b) HTML (c) JavaScript
  7. 7.📱 The screen is 1366px wide. Does the rule inside @media apply?
    p {
      font-size: 12px;
    }
    @media (min-width: 480px) {
      p {
        font-size: 18px;
      }
    }
    (a) No (b) Yes
  8. 8.⚖️ What colour is the text of this element?
    <h2 class="box" id="top">Hi</h2>
    CSS:
    h2 { color: blue; }
    h2 { color: purple; }
    (a) purple (b) yellow (c) green (d) blue
  9. 9.🎯 Which element does the selector #main style? (a) <h1 id="main"> (b) <h2 class="note"> (c) <h1 class="main"> (d) <h1 id="logo">
  10. 10.🖌️ Which CSS property picks the font style? (a) font-family (b) font-size (c) background-color (d) text-align
  11. 11.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 250px;
      justify-content: flex-end;
    }
    Inside are 3 boxes, each 60px wide (no margins).
  12. 12.🌈 Which colour is #ff00ff? (a) magenta (b) red (c) blue (d) black
  13. 13.🌈 Which colour of light is strongest in rgb(46, 153, 27)? (a) red (b) green (c) blue
  14. 14.✍️ How many declarations (property: value pairs) are in this rule?
    p {
      margin: 10px;
      background-color: yellow;
      padding: 8px;
      font-size: 20px;
    }
  15. 15.What does background-color do? (a) centres a heading (b) makes the text bold (c) makes letters bigger (d) colours behind the text
  16. 16.🖌️ What colour are the letters?
    h1 {
      color: purple;
      background-color: red;
      font-size: 24px;
      text-align: left;
    }
    (a) red (b) purple (c) yellow
  17. 17.🖌️ Where does the text sit on its line?
    h2 {
      font-size: 16px;
      color: orange;
      background-color: green;
      text-align: center;
    }
    (a) on the left (b) on the right (c) in the middle
  18. 18.✍️ CSS declarations go inside which brackets? (a) ( ) (b) { } (c) [ ] (d) < >
  19. 19.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 190px;
      justify-content: center;
    }
    Inside are 3 boxes, each 50px wide (no margins).
  20. 20.✍️ Which property is set to italic in this rule?
    h1 {
      font-style: italic;
      border: 2px solid;
      background-color: yellow;
    }
    (a) italic (b) color (c) font-style (d) font-size
  21. 21.🎯 What kind of selector is .star? (a) a class selector (b) an element selector (c) an id selector
  22. 22.✍️ How many declarations (property: value pairs) are in this rule?
    h1 {
      color: red;
      margin: 10px;
    }
  23. 23.🎯 Which element does the selector #hero style? (a) <li class="menu"> (b) <h2 id="top"> (c) <h2 id="hero"> (d) <h2 class="hero">
  24. 24.🌈 Which colour is #00ff00? (a) white (b) bright green (c) blue (d) red
  25. 25.🌈 In #aa0000 the red part is the hex number aa. What is it as a normal number?
  26. 26.✍️ What is the selector in this CSS rule?
    .box {
      text-align: center;
      font-size: 20px;
      font-style: italic;
    }
    (a) h2 (b) 20px (c) text-align (d) .box
  27. 27.🎯 How many elements on a page should have the same id? (a) 2 (b) 1 (c) any number (d) 5
  28. 28.Which of these does JavaScript do? (a) rounds box corners (b) changes the page live (c) makes a link (d) gives the page structure
  29. 29.✍️ What is the selector in this CSS rule?
    li {
      border: 2px solid;
      color: red;
    }
    (a) li (b) red (c) body (d) border
  30. 30.🌈 Which hex code is yellow? (a) #00ff00 (b) #ff0000 (c) #000000 (d) #ffff00
  31. 31.✍️ What is the selector in this CSS rule?
    p {
      color: red;
      background-color: yellow;
    }
    (a) .note (b) p (c) color (d) yellow
  32. 32.⚖️ What colour is the text of this element?
    <h2 class="star" id="intro">Hi</h2>
    CSS:
    h2 { color: white; }
    .star { color: red; }
    #intro { color: yellow; }
    (a) yellow (b) red (c) white (d) orange
  33. 33.🎯 What kind of selector is #main? (a) an id selector (b) a class selector (c) an element selector
  34. 34.📦 In the box model, which part is space inside the border? (a) content (b) margin (c) padding (d) border
  35. 35.⚖️ What colour is the text of this element?
    <h1 class="note" id="end">Hi</h1>
    CSS:
    h1 { color: blue; }
    h1 { color: black; }
    (a) blue (b) orange (c) green (d) black
  36. 36.🎯 Which element does the selector .note style? (a) <li class="big"> (b) <li class="note"> (c) <div class="red"> (d) <li id="note">
  37. 37.📱 What does a media query check? (a) the screen width (b) the time of day (c) the page title (d) the battery level
  38. 38.🌈 Which hex code is cyan? (a) #0000ff (b) #00ffff (c) #ffff00 (d) #ffffff
  39. 39.True or false: JavaScript gives the page structure. (a) False (b) True
  40. 40.💪 How much empty space (px) is left after the last box?
    .row {
      display: flex;
      width: 200px;
      justify-content: flex-start;
    }
    Inside are 2 boxes, each 80px wide (no margins).

Answer key

  1. width
  2. li
  3. the text or picture
  4. yellow
  5. an element selector
  6. JavaScript
  7. Yes
  8. purple
  9. <h1 id="main">
  10. font-family
  11. 70
  12. magenta
  13. green
  14. 4
  15. colours behind the text
  16. purple
  17. in the middle
  18. { }
  19. 20
  20. font-style
  21. a class selector
  22. 2
  23. <h2 id="hero">
  24. bright green
  25. 170
  26. .box
  27. 1
  28. changes the page live
  29. li
  30. #ffff00
  31. p
  32. yellow
  33. an id selector
  34. padding
  35. black
  36. <li class="note">
  37. the screen width
  38. #00ffff
  39. False
  40. 40

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