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

Answer key

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

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