|
Posted by John Hosking on 05/27/07 10:34
JWL wrote:
> Suppose I have a div containing headings and paragraphs, and I decide to
> add some margin or padding to the left side of the div to create some
> whitespace. My question is, in this situation, is there any reason
> whatsoever to choose padding over margin or vise versa?
>
> <div id="contentcontainer">
> <h1>heading</h1>
> <p>para</p>
> <ul>
> <li>list etc.</li>
> </ul>
> </div>
>
> #contentcontainer {
> padding-left: 2em;
> /* Or... */
> margin-left: 2em; /* ? */
> }
Not enough information for me. It depends on the (real) content of the
div and on the elements to its left. Text or graphics? Background
colors? Does the div have a border? What margins and paddings do the
neighboring elements have? Etc.
If you're equally happy with the results either way, then, no, there's
no reason to prefer one to the other (except maybe, heh, "margin" is one
character shorter than "padding", so you save on code size LOL).
--
John
Navigation:
[Reply to this message]
|