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

Answer key

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

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