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