View Single Post
Old 09-27-2024, 11:55 AM   #11
nabsltd
Fanatic
nabsltd ought to be getting tired of karma fortunes by now.nabsltd ought to be getting tired of karma fortunes by now.nabsltd ought to be getting tired of karma fortunes by now.nabsltd ought to be getting tired of karma fortunes by now.nabsltd ought to be getting tired of karma fortunes by now.nabsltd ought to be getting tired of karma fortunes by now.nabsltd ought to be getting tired of karma fortunes by now.nabsltd ought to be getting tired of karma fortunes by now.nabsltd ought to be getting tired of karma fortunes by now.nabsltd ought to be getting tired of karma fortunes by now.nabsltd ought to be getting tired of karma fortunes by now.
 
Posts: 524
Karma: 8500000
Join Date: Aug 2013
Location: Hamden, CT
Device: Kindle Paperwhite (11th gen), Scribe, Kindle 4 Touch
Quote:
Originally Posted by foosion View Post
I don't understand how the difference works for things such as p and h1 with pure text (no borders, decoration, etc.). When I compare, for example, "margin: 1em" to "padding: 1em" in a p or h1 definition, the padding takes up a bit more space. Why is this?
This could just be a quirk of that particular renderer. Testing more renderers might help.

Other than the inside/outside part, the biggest difference between margins and padding is that margins collapse and padding does not. An example:
Code:
.p1 {
margin-top: 1em;
margin-bottom: 1em;
}

.p2 {
padding-top: 1em;
padding-bottom: 1em;
}
Consecutive paragraphs of class p1 will have 1em of space between them, while consecutive paragraphs of class p2 will have 2em of space. This is because margins collapse to the larger of the two shared margin values.
nabsltd is offline   Reply With Quote