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