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