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