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