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