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

Answer key

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

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