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