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