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