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