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