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