HTML & CSS · Junior · Question 14 of 75

How does padding differ from margin?

Explanation

The box model order is content → padding → border → margin. padding sits inside the border and is painted with the element's background; margin is outside and transparent. Also, vertical margins of adjacent blocks can collapse while padding never does, and margin can be negative while padding cannot.

Further reading

Problem with a question

HTML & CSS · Junior · question 14

Test yourself

Take the HTML & CSS · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz