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

Answer key

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

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