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