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