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