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