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