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

Answer key

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

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