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