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,817
Replies
2
Views
6,207
Replies
6
Views
7,987
Replies
0
Views
64,715
Newer threads
Replies
4
Views
3,961
Replies
2
Views
3,866
Replies
1
Views
2,504
Replies
1
Views
3,083
Replies
3
Views
2,779
Latest threads
Replies
1
Views
88
Replies
1
Views
179
Replies
4
Views
385
Replies
11
Views
527
Replies
2
Views
229
Recommended threads
Replies
6
Views
2,548
Replies
28
Views
11,259
Replies
8
Views
5,029
Replies
0
Views
1,705

Latest postsNew threads

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