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