← CSS test lesson New set →

CSS Worksheet: Practice Test

HTML and CSS lesson 20: CSS test · Set 579 · 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 weakest? (a) an element selector (b) an id selector (c) a class selector
  2. 2.✍️ How many declarations (property: value pairs) are in this rule?
    h2 {
      font-size: 20px;
      width: 300px;
      color: red;
      font-weight: bold;
    }
  3. 3.🖌️ What colour is behind the letters?
    h2 {
      text-align: center;
      color: purple;
      font-size: 28px;
      background-color: white;
    }
    (a) white (b) black (c) purple
  4. 4.📦 How much space top to bottom (px) does this box take in all, margin included?
    .box {
      height: 200px;
      padding: 30px;
      border: 1px solid black;
      margin: 10px;
    }
  5. 5.🌈 In #e40000 the red part is the hex number e4. What is it as a normal number?
  6. 6.🎯 Which element does the selector .red style? (a) <li class="box"> (b) <li class="red"> (c) <div class="star"> (d) <li id="red">
  7. 7.✍️ CSS declarations go inside which brackets? (a) ( ) (b) { } (c) [ ] (d) < >
  8. 8.💪 How wide (px) is each gap between two boxes?
    .row {
      display: flex;
      width: 110px;
      justify-content: space-between;
    }
    Inside are 2 boxes, each 50px wide (no margins).
  9. 9.💪 How much empty space (px) is before the first box?
    .row {
      display: flex;
      width: 260px;
      justify-content: center;
    }
    Inside are 2 boxes, each 60px wide (no margins).
  10. 10.📱 The screen is 414px wide. Does the rule inside @media apply?
    p {
      font-size: 24px;
    }
    @media (min-width: 600px) {
      p {
        font-size: 26px;
      }
    }
    (a) No (b) Yes
  11. 11.🎯 Can many elements share the same class? (a) No (b) Yes
  12. 12.🖌️ Which CSS property picks the font style? (a) background-color (b) color (c) font-family (d) font-size
  13. 13.⚖️ What colour is the text of this element?
    <p class="box" id="intro">Hi</p>
    CSS:
    .box { color: black; }
    .box { color: green; }
    (a) yellow (b) green (c) red (d) black
  14. 14.True or false: HTML checks a quiz answer. (a) False (b) True
  15. 15.⚖️ Two rules with the same selector set a colour. Which one wins? (a) the first one (b) the shorter one (c) the later one (d) neither
  16. 16.🔍 Which is the odd one out? (a) makes a form box (b) adds space around boxes (c) gives the page structure (d) puts a picture on a page
  17. 17.🎯 What kind of selector is h1? (a) an id selector (b) an element selector (c) a class selector
  18. 18.🌈 Hex digits go 0 to 9, then A to which letter? (a) Z (b) F (c) G (d) J
  19. 19.✍️ Which sign goes between a property and its value? (a) : (b) - (c) ; (d) =
  20. 20.📱 max-width: 600px applies when the screen is ___. (a) turned off (b) 600px or wider (c) exactly 1000px (d) 600px or narrower
  21. 21.✍️ Which property is set to yellow in this rule?
    li {
      width: 300px;
      padding: 8px;
      background-color: yellow;
    }
    (a) yellow (b) margin (c) background-color (d) padding
  22. 22.✍️ What value is given to text-align in this rule?
    h1 {
      color: red;
      text-align: center;
    }
    (a) 10px (b) center (c) text-align (d) yellow
  23. 23.⚖️ Which selector is the strongest? (a) a class selector (b) an id selector (c) an element selector
  24. 24.✍️ How does a CSS comment start? (a) # (b) <!-- (c) // (d) /*
  25. 25.Which of these is the content? (a) space inside the border (b) a solid or dotted edge (c) the text or picture (d) the gap round content
  26. 26.🎯 Which CSS selector matches this element?
    <div class="note" id="intro">Hello</div>
    (a) #note (b) .big (c) .intro (d) #intro
  27. 27.🎯 Which sign starts an id selector? (a) & (b) @ (c) . (d) #
  28. 28.🖌️ Where does the text sit on its line?
    p {
      font-size: 20px;
      background-color: white;
      text-align: center;
      color: orange;
    }
    (a) on the left (b) on the right (c) in the middle
  29. 29.🖌️ Which CSS property sets the letter colour? (a) background-color (b) color (c) font-size (d) font-family
  30. 30.📱 The screen is 375px wide. What font-size (px) does the paragraph get?
    p {
      font-size: 20px;
    }
    @media (min-width: 600px) {
      p {
        font-size: 26px;
      }
    }
  31. 31.⚖️ What colour is the text of this element?
    <p class="big" id="end">Hi</p>
    CSS:
    #end { color: blue; }
    #end { color: red; }
    (a) blue (b) white (c) red (d) purple
  32. 32.📦 How wide (px) is this box from the outer edge of its left border to the outer edge of its right border?
    .box {
      width: 290px;
      padding: 10px;
      border: 5px solid black;
      margin: 0px;
    }
  33. 33.Which of these does JavaScript do? (a) makes a form box (b) puts a picture on a page (c) sets colours and fonts (d) checks a quiz answer
  34. 34.✍️ Which sign ends each CSS declaration? (a) : (b) ; (c) . (d) ,
  35. 35.📦 In the box model, which part is the gap to other boxes? (a) padding (b) content (c) border (d) margin
  36. 36.🎯 How many elements on a page should have the same id? (a) 2 (b) 1 (c) 5 (d) any number
  37. 37.🖌️ Where does the text sit on its line?
    p {
      background-color: red;
      color: black;
      text-align: left;
      font-size: 16px;
    }
    (a) in the middle (b) on the left (c) on the right
  38. 38.✍️ How many declarations (property: value pairs) are in this rule?
    h2 {
      font-size: 20px;
      padding: 8px;
    }
  39. 39.🌈 Which colour is rgb(255, 255, 0)? (a) yellow (b) magenta (c) blue (d) bright green
  40. 40.🧩 Which language makes headings and lists? (a) CSS (b) JavaScript (c) HTML

Answer key

  1. an element selector
  2. 4
  3. white
  4. 282
  5. 228
  6. <li class="red">
  7. { }
  8. 10
  9. 70
  10. No
  11. Yes
  12. font-family
  13. green
  14. False
  15. the later one
  16. adds space around boxes
  17. an element selector
  18. F
  19. :
  20. 600px or narrower
  21. background-color
  22. center
  23. an id selector
  24. /*
  25. the text or picture
  26. #intro
  27. #
  28. in the middle
  29. color
  30. 20
  31. red
  32. 320
  33. checks a quiz answer
  34. ;
  35. margin
  36. 1
  37. on the left
  38. 2
  39. yellow
  40. HTML

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