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