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