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

Answer key

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

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