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

Answer key

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

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