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

Answer key

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

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