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