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