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