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

Answer key

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

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