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