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