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