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

Answer key

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

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