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
• 12,890 points
67 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
• 11,450 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
• 12,890 points
57 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
• 11,450 points
93 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
• 11,450 points
2,397 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
• 11,450 points
107 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
• 12,890 points
59 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
• 12,890 points
128 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,898 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
• 11,450 points
278 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
• 11,450 points
314 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