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