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

Answer key

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

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