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