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

Answer key

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

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