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