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