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

Answer key

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

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