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