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

Answer key

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

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