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