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

Answer key

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

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