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