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