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