Reputation: 2868
UPDATED
I know padding make distance from border but
Why we must use padding for absolute position ?
I have this :
#Menu ul li a{width:126px;
height:20px;
text-align:center;
color:Black;
position:absolute;
text-decoration:none;
background-color:inherit;
padding:15px 0 15px 0;}
But why I should set padding-top and padding-bottom too? ( if don't ,height won't be set to 20.)
will padding be set form it's parent coord or the coordinates of browser(document)?
thanks
Upvotes: 1
Views: 529
Reputation: 308
I think Scott's comments have answered your question. In answer to your 2nd question, maybe there's another selector within your code affecting the height of the anchor as the code works with or without the padding-top/bottom.
With height: 20px you're creating a block of 20px in height, then providing the combination of margins do not exceed 20px, the text of the anchor is positioned within this 'block' using the padding.
Upvotes: 0
Reputation: 943510
Usually to separate the content of the element from the border (or the edge of the background).
Upvotes: 0
Reputation: 21882
Padding applies the measurement to the inside of the element. It's often desired to not have text or other elements at the very edge of a block element. Padding is often not about positioning, it's about aesthetics.
Upvotes: 3