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

Answer key

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

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