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