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