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