in Technology by
What are difference between Margin v/s Padding?

1 Answer

0 votes
by

During the designing of user interfaces, sometimes there is confusion occurs between padding and margin. They are used to provide extra space or a gap. Both margin and padding targets the four sides of an element and can also work without the border property, but they differ in many ways.

The main difference between the padding and margin is:

  • Padding provides the space between the border and the content of an element.
  • Margin provides the space between the border and outer elements.

So, when we require the space between the elements, then it is better to use margin, and when we need the space between the inner element and the parent box, then go for padding.

The basic differences between margin and padding are tabulated as follows:

Margin Padding
Margin is said to be the outer space of an element, i.e., the margin is the space outside of the element's border. Padding is said to be the inner space of an element, i.e., the padding is the space inside of the element's border.
We can set the margin to auto. We cannot set the padding to auto.
It can be negative or any float number. It does not allow negative values.
Styling of an element such as background color does not affect the margin. Padding is affected by the styling of an element, such as background color.

We can see the following image to clear the difference between the margin and padding. In this image, the margin indicates the area outside the border and the padding indicates the area inside the border.

Related questions

0 votes
    I have been working on the Snackbar and achieved in my project successfully. However, there is this little ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 6, 2022 in Education by JackTerrance
0 votes
    In tf.nn.max_pool of tensorflow what is the difference between 'SAME' and 'VALID'? I read in here that ... pool means in tensorflow? Select the correct answer from above options...
asked Jan 24, 2022 in Education by JackTerrance
0 votes
    I want to use MLPs to solve regression problem. I have inputs with variable length to fix this I ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 1, 2022 in Education by JackTerrance
0 votes
    I'm a little new to the web development scene and I was having a very persistent problem ... ? C̶h̶r̶o̶m̶e̶ ̶m̶u̶s̶t̶ ̶b̶e̶ ̶i̶n̶c̶r̶e̶d̶i̶b̶l̶y̶ ̶b̶u̶g̶g̶y̶ ̶o̶n̶ ̶U̶b̶u̶n̶t̶u̶!̶...
asked Jan 13, 2022 in Education by JackTerrance
0 votes
    The ___________ class adds a rounded border around an element with a gray background color and some padding. ... .alert .jumbotron Select the correct answer from above options...
asked Dec 10, 2021 in Education by JackTerrance
0 votes
    portrait and landscape are ……….. 1.paper layout 2. Page layout 3. Page orientation 4. Page margin . Select the correct answer from above options...
asked Dec 31, 2021 in Education by JackTerrance
0 votes
    By default, the ______ margin settings are applied to an Excel sheet. * a. Wide b. Normal c. Thin d. Narrow Select the correct answer from above options...
asked Nov 29, 2021 in Education by JackTerrance
0 votes
    Explain the features of Endpoint v/s ANTI-VIRUS?...
asked Oct 24, 2020 in Technology by JackTerrance
0 votes
    Select the correct answer from above options...
asked Nov 25, 2021 in Education by JackTerrance
0 votes
0 votes
    Determine the voltage V after taking the inverse transform (12 + 60/s + 10/(s+5)). (a) 12δ(t)-(60- ... Questions for GATE EC Exam, Network Theory MCQ (Multiple Choice Questions)...
asked Oct 16, 2021 in Education by JackTerrance
...