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