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