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