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