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

Answer key

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

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