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