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