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