CSS padding properties
Notes:
CSS Padding Area Properties
CSS padding-top property:
It is used to specify the amount of area to be cleared above the content area of an html element
Values: length | %
CSS padding-right property:
It is used to specify the amount of area to be cleared on the right hand side of the content area of an html element
Values: length | %
CSS padding-bottom property:
It is used to specify the amount of area to be cleared below the content area of an html element
Values: length | %
CSS padding-left property:
It is used to specify the amount of area to be cleared on the left hand side of the content area of an html element
Values: length | %
CSS padding short hand property:
It is used to specify the amount of area to be cleared around the content area of an html element
Values: space separated list values (1, 2, 3, and 4)
Ex:
padding: 10px;
indicates: padding-top:10px; padding-right:10px; padding-bottom:10px; padding-left:10px;
Ex:
padding: 10px 20px;
indicates: padding-top:10px; padding-bottom:10px; padding-right:20px; padding-left:20px;
Ex:
padding: 10px 20px 10px ;
indicates: padding-top:10px; padding-right:20px; padding-left:20px; padding-bottom:10px;
Ex:
padding: 10px 10px 10px 10px ;
indicates: padding-top:10px; padding-right:10px; padding-bottom:10px; padding-left:10px;
Interview Questions:
1. Negative values are allowed while setting padding for an html element.
a. true
b. false
Answer: b
2. Negative values are allowed while setting margin for an html element.
a. true
b. false
Answer: a
3. Which CSS property is used to set only the left padding?
a. padding
b. left-padding
c. padding-left
d.padding-left-only
Answer: c