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

Answer key

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

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