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

Answer key

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

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