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

Answer key

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

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