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