Solved Need help about "PADDING" in CSS

Status
Not open for further replies.

mr.lashpash

New Member
Thread author
Oct 18, 2012
58
2
8
36
Multan
Hi i am trying to learn XHTML alongwith CSS and there is little confusion about PADDING.
Could anyone explain this or tell me what are core rules of this
Thanks
 
Padding is used to make an element bigger than it's content.
For example, if you have a div with text in it and you want to give it a background color but the background should be bigger than the text.

HtLNH.png


In this case you would put padding on the div and the element will become bigger.

BzfQ6.png


Another example is if you have an image with a border. If you don't want the border to hit the image you can give some padding the the image and this will push the border in the specified direction.

Padding is really useful if the content is dynamic, meaning that the length of the text (or whatever is within an element) can vary. Padding doesn't care how big the element is and will enlarge it no matter what.

Hope that made any kind of sense :)
 
Upvote 0
Status
Not open for further replies.

You may also like...