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