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

Answer key

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

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