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