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

Answer key

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

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