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