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

Answer key

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

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