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

Answer key

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

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