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