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

Answer key

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

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