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