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

Answer key

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

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