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