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