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