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