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