← CSS rules: selector, property, value lesson New set →

CSS Worksheet: CSS Rules and Syntax

HTML and CSS lesson 12: CSS rules: selector, property, value · Set 630 · 40 questions
TalentJR

Code tip (Colon in the middle, semicolon at the end): A rule is: selector { property: value; property: value; } The property is before the colon, the value after it; a semicolon ends each declaration. Count the property: value; lines to count the declarations.

NameDateTime takenScore ___ / 40
  1. 1.✍️ Which sign ends each CSS declaration? (a) . (b) , (c) : (d) ;
  2. 2.✍️ What is the selector in this CSS rule?
    li {
      text-align: center;
      padding: 8px;
      color: red;
      font-size: 20px;
    }
    (a) text-align (b) li (c) body (d) 8px
  3. 3.✍️ Which property is set to 2px solid in this rule?
    h1 {
      border: 2px solid;
      font-size: 20px;
      width: 300px;
    }
    (a) width (b) 2px solid (c) font-style (d) border
  4. 4.✍️ In color: blue; which part is the property? (a) blue (b) ; (c) : (d) color
  5. 5.✍️ CSS declarations go inside which brackets? (a) [ ] (b) < > (c) { } (d) ( )
  6. 6.✍️ What is the selector in this CSS rule?
    body {
      font-size: 20px;
      border: 2px solid;
    }
    (a) .box (b) 2px solid (c) body (d) font-size
  7. 7.✍️ How many declarations (property: value pairs) are in this rule?
    p {
      padding: 8px;
    }
  8. 8.✍️ How many declarations (property: value pairs) are in this rule?
    h1 {
      border: 2px solid;
    }
  9. 9.✍️ What value is given to background-color in this rule?
    body {
      font-size: 20px;
      background-color: yellow;
      width: 300px;
    }
    (a) yellow (b) 10px (c) 8px (d) background-color
  10. 10.✍️ What is the selector in this CSS rule?
    p {
      font-size: 20px;
      border: 2px solid;
    }
    (a) font-size (b) .note (c) p (d) 2px solid
  11. 11.✍️ How many declarations (property: value pairs) are in this rule?
    .note {
      text-align: center;
      font-style: italic;
      border: 2px solid;
      width: 300px;
    }
  12. 12.✍️ What value is given to padding in this rule?
    .note {
      border: 2px solid;
      padding: 8px;
      color: red;
    }
    (a) padding (b) bold (c) 2px solid (d) 8px
  13. 13.✍️ What is the selector in this CSS rule?
    .note {
      background-color: yellow;
      font-style: italic;
      width: 300px;
    }
    (a) #top (b) italic (c) .note (d) background-color
  14. 14.✍️ What value is given to margin in this rule?
    .box {
      text-align: center;
      border: 2px solid;
      margin: 10px;
    }
    (a) 10px (b) bold (c) margin (d) 8px
  15. 15.✍️ What is the selector in this CSS rule?
    body {
      color: red;
      border: 2px solid;
      text-align: center;
      padding: 8px;
    }
    (a) color (b) 2px solid (c) .box (d) body
  16. 16.✍️ How does a CSS comment start? (a) # (b) /* (c) <!-- (d) //
  17. 17.✍️ What is the selector in this CSS rule?
    body {
      font-style: italic;
      font-weight: bold;
      width: 300px;
      margin: 10px;
    }
    (a) font-style (b) .box (c) bold (d) body
  18. 18.✍️ What value is given to font-weight in this rule?
    .box {
      background-color: yellow;
      font-weight: bold;
      font-style: italic;
    }
    (a) 300px (b) 2px solid (c) bold (d) font-weight
  19. 19.✍️ In color: blue; which part is the value? (a) ; (b) : (c) color (d) blue
  20. 20.✍️ How many declarations (property: value pairs) are in this rule?
    #top {
      font-weight: bold;
      background-color: yellow;
    }
  21. 21.✍️ Which sign goes between a property and its value? (a) ; (b) : (c) = (d) -
  22. 22.✍️ What value is given to width in this rule?
    .box {
      color: red;
      font-size: 20px;
      width: 300px;
    }
    (a) width (b) italic (c) 300px (d) red
  23. 23.✍️ How many declarations (property: value pairs) are in this rule?
    h2 {
      border: 2px solid;
    }
  24. 24.✍️ What value is given to font-weight in this rule?
    li {
      margin: 10px;
      font-weight: bold;
      color: red;
      background-color: yellow;
    }
    (a) font-weight (b) bold (c) 2px solid (d) 300px
  25. 25.✍️ What value is given to color in this rule?
    h1 {
      color: red;
      width: 300px;
    }
    (a) color (b) 20px (c) center (d) red
  26. 26.✍️ Which property is set to 2px solid in this rule?
    .box {
      text-align: center;
      border: 2px solid;
      font-size: 20px;
      width: 300px;
    }
    (a) 2px solid (b) width (c) border (d) font-style
  27. 27.✍️ How many declarations (property: value pairs) are in this rule?
    h2 {
      color: red;
      padding: 8px;
      width: 300px;
    }
  28. 28.✍️ Which property is set to bold in this rule?
    h1 {
      text-align: center;
      font-weight: bold;
      background-color: yellow;
      padding: 8px;
    }
    (a) width (b) border (c) bold (d) font-weight
  29. 29.✍️ Which property is set to 2px solid in this rule?
    h2 {
      border: 2px solid;
      font-style: italic;
    }
    (a) font-style (b) border (c) width (d) 2px solid
  30. 30.✍️ What is the selector in this CSS rule?
    p {
      font-size: 20px;
      color: red;
      text-align: center;
    }
    (a) red (b) p (c) .note (d) font-size
  31. 31.✍️ What is the selector in this CSS rule?
    h2 {
      width: 300px;
      font-style: italic;
    }
    (a) h1 (b) width (c) italic (d) h2
  32. 32.✍️ Which property is set to 20px in this rule?
    #top {
      font-size: 20px;
      text-align: center;
      margin: 10px;
      background-color: yellow;
    }
    (a) 20px (b) background-color (c) text-align (d) font-size
  33. 33.✍️ Which property is set to 8px in this rule?
    .box {
      text-align: center;
      padding: 8px;
      background-color: yellow;
      border: 2px solid;
    }
    (a) 8px (b) border (c) padding (d) font-weight
  34. 34.✍️ How many declarations (property: value pairs) are in this rule?
    .note {
      width: 300px;
      color: red;
      background-color: yellow;
      padding: 8px;
    }
  35. 35.✍️ Which property is set to bold in this rule?
    #top {
      font-weight: bold;
      font-style: italic;
      width: 300px;
    }
    (a) width (b) border (c) bold (d) font-weight
  36. 36.✍️ How many declarations (property: value pairs) are in this rule?
    .note {
      width: 300px;
      font-weight: bold;
      padding: 8px;
    }
  37. 37.✍️ What is the selector in this CSS rule?
    .box {
      margin: 10px;
      font-weight: bold;
    }
    (a) h2 (b) margin (c) bold (d) .box
  38. 38.✍️ What is the selector in this CSS rule?
    h1 {
      text-align: center;
      width: 300px;
      margin: 10px;
      color: red;
    }
    (a) 300px (b) text-align (c) h1 (d) p
  39. 39.✍️ What is the selector in this CSS rule?
    body {
      border: 2px solid;
      background-color: yellow;
      width: 300px;
    }
    (a) body (b) .box (c) border (d) yellow
  40. 40.✍️ What is the selector in this CSS rule?
    h1 {
      text-align: center;
      font-size: 20px;
      padding: 8px;
    }
    (a) 20px (b) text-align (c) p (d) h1

Answer key

  1. ;
  2. li
  3. border
  4. color
  5. { }
  6. body
  7. 1
  8. 1
  9. yellow
  10. p
  11. 4
  12. 8px
  13. .note
  14. 10px
  15. body
  16. /*
  17. body
  18. bold
  19. blue
  20. 2
  21. :
  22. 300px
  23. 1
  24. bold
  25. red
  26. border
  27. 3
  28. font-weight
  29. border
  30. p
  31. h2
  32. font-size
  33. padding
  34. 4
  35. font-weight
  36. 3
  37. .box
  38. h1
  39. body
  40. h1

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