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