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

Answer key

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

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