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