When I should use Margin and Padding in CSS ?

hoangvu

New member
Joined
Jun 6, 2012
Messages
1,835
Points
0
It's difficult for me to use padding and margin in Css, are they different ?
Anyone know about When I should use Margin and Padding in CSS and any Tips ?

Thanks
 

Frank

New member
Joined
Jul 7, 2012
Messages
40
Points
0
Use margin for boxes contain ojeccts ( texts, images..) and using padding for those ojects into boxes
 

unni6849

New member
Joined
Oct 5, 2012
Messages
17
Points
0
Margin and Padding are important tools in the Dreamweaver.You should add margin in order to centralize the web pages and padding is used to align the text element in the CSS document.
 

leszek

New member
Joined
Oct 27, 2012
Messages
6
Points
0
here you will find all info that you need

w3schools.com/css/css_margin.asp

w3schools.com/css/css_padding.asp
 

telma

New member
Joined
Feb 9, 2013
Messages
4
Points
0
Hello..
yes you are right friend.w3school.com is the most easy site where we learn about css.Thank you for the posting.
 

MechanicWeb-shoss

New member
Joined
Apr 11, 2016
Messages
20
Points
0
It's difficult for me to use padding and margin in Css, are they different ?
Anyone know about When I should use Margin and Padding in CSS and any Tips ?

Thanks
Margin adds a gap outside of an element
Padding adds a gap inside of an element

For example, you have a div element with border and background color. If you add padding to it, the background color and border will be displayed around and through the gap. However, if you add margin to the div, the border and background color will not be displayed around the gap but displayed inside.

Hope that helps.
 

PenguinManiac

New member
Joined
Jun 27, 2017
Messages
200
Points
0
PenguinManiac
Sums it up nicely.
Since you asked about usage, I'd also add that margins are subject to margin collapse: so, when two vertical margins overlap, under certain circumstances the larger margin might override the other. This is more common than it seems, so keep this in mind when you're facing spacing issues while using margins.
 

onliveserver

New member
Joined
Jun 22, 2017
Messages
29
Points
0
Hello Team,

Margin is using to outside space of Div and Padding is inner-side space of Div.
 

ccwoods03

New member
Joined
Aug 6, 2017
Messages
1
Points
0
They both are great tools to know or learn when it comes to web design and development. They add spaces between your items such as text, images, and buttons. They are a little different in how they work, but overall they practically do the same thing.
 
Older threads
Replies
1
Views
6,320
Replies
2
Views
6,711
Replies
6
Views
8,692
Replies
0
Views
71,416
Newer threads
Replies
4
Views
4,310
Replies
2
Views
4,473
Replies
1
Views
2,716
Replies
1
Views
3,323
Replies
3
Views
3,045
Latest threads
Replies
0
Views
29
Replies
0
Views
31
Replies
1
Views
41
Replies
3
Views
105
Recommended threads
Replies
7
Views
2,469
Replies
24
Views
7,332
Replies
7
Views
9,544
Top