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