When I should use Margin and Padding in CSS ?

hoangvu

New member
Joined
Jun 6, 2012
Messages
1,844
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
5,886
Replies
2
Views
6,258
Replies
6
Views
8,077
Replies
0
Views
65,333
Newer threads
Replies
4
Views
3,999
Replies
2
Views
3,936
Replies
1
Views
2,528
Replies
1
Views
3,126
Replies
3
Views
2,817
Latest threads
Replies
1
Views
105
Replies
1
Views
128
Replies
1
Views
246
Replies
0
Views
255
Replies
0
Views
267
Recommended threads
Replies
2
Views
5,134
Replies
3
Views
1,629
Replies
2
Views
7,140
Replies
17
Views
4,201

Referral contests

Referral link for :

Sponsors

Popular tags

You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an alternative browser.

Top