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

Answer key

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

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