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

Answer key

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

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