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

Answer key

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

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