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