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

Answer key

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

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