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

Answer key

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

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