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

Answer key

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

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