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