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

Answer key

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

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