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