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