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