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