You are here: Re: margin or padding? « HTML « IT news, forums, messages
Re: margin or padding?

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация