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