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