When to use margin vs padding in CSS

0 votes
Is there a certain rule or guideline that should be followed when selecting whether to use margin and when to use padding when developing CSS?
Jun 23 in CSS by Edureka
• 11,040 points
29 views

1 answer to this question.

0 votes

MARGIN vs PADDING :

  1. Margin is used in an element to create distance between that element and other elements of the page. Where padding is used to create distance between content and border of an element.

  2. Margin is not part of an element where padding is part of the element.

answered Jun 28 by Edureka
• 9,540 points

Related Questions In CSS

0 votes
0 answers

What is the difference between id and class in CSS, and when should I use them?

#main { background: #000; ...READ MORE

Aug 18 in CSS by Edureka
• 11,040 points
17 views
0 votes
1 answer

How to insert spaces/tabs in text using HTML/CSS

For spaces, use  , for (less than, ...READ MORE

answered Jun 1 in CSS by Edureka
• 9,540 points
36 views
0 votes
1 answer

How to add border in my clip-path: polygon(); CSS style

Using an SVG Dilation Filter to Add ...READ MORE

answered Jun 21 in CSS by Edureka
• 9,540 points
822 views
0 votes
1 answer

Should I use px or rem value units in my CSS?

The answer is yes because using px ...READ MORE

answered Jun 21 in CSS by Edureka
• 9,540 points
33 views
0 votes
0 answers

What does auto do in margin: 0 auto?

What does auto do in margin: 0 ...READ MORE

Jul 11 in CSS by Edureka
• 11,040 points
24 views
0 votes
0 answers

How do negative margins in CSS work and why is (margin-top:-5 != margin-bottom:5)?

A common trick for vertical positioning elements ...READ MORE

Jul 18 in CSS by Edureka
• 11,040 points
32 views
0 votes
2 answers

Define a SQL query? What is the difference between SELECT and UPDATE Query? How do you use SQL in SAS?

HI.. SQL is Structured Query Language, which is ...READ MORE

answered Aug 8, 2020 in PHP by anonymous
5,051 views
0 votes
1 answer

When to use IMG vs. CSS background-image?

You can transition a div's background image ...READ MORE

answered Jun 10 in CSS by Edureka
• 9,540 points
112 views
0 votes
1 answer

How to set Bullet colors in UL/LI html lists via CSS without using any images or span tags

I use jQuery for this: jQuery('li').wrapInner('<span class="li_content" />'); & ...READ MORE

answered May 27 in CSS by Edureka
• 9,540 points
127 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP