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

Answer key

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

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