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, 2022 in CSS by Edureka
• 13,620 points
405 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, 2022 by Edureka
• 12,690 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, 2022 in CSS by Edureka
• 13,620 points
352 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, 2022 in CSS by Edureka
• 12,690 points
604 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, 2022 in CSS by Edureka
• 12,690 points
6,784 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, 2022 in CSS by Edureka
• 12,690 points
552 views
0 votes
0 answers

What does auto do in margin: 0 auto?

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

Jul 11, 2022 in CSS by Edureka
• 13,620 points
330 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, 2022 in CSS by Edureka
• 13,620 points
895 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
10,540 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, 2022 in CSS by Edureka
• 12,690 points
876 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, 2022 in CSS by Edureka
• 12,690 points
1,032 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