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