Using a margin with negative value is a bad practice?
Example:
margin-top: -3px;
Using a margin with negative value is a bad practice?
Example:
margin-top: -3px;
No, negative CSS margin is not bad practice. Negative margin is a great way to deny paddings in an element, when some inner element should be positioned in such a way.
Also, I think that the only 100% reliable way, supported by all browsers, to centralize an element vertically and horizontally in relation to a parent element, is to use negative margins, as follows:.classe_css{
left:50%;
top:50%;
position: relative;
margin-left:-40px; /* -1/2 width */
margin-top:-40px; /* -1/2 height */
}
negative Margin is not necessarily a bad practice, for example you can use the faux-columns technique without images.
Negative values for margin properties are allowed, but there may be implementation-specific limits.
- W3C, about margin properties
This excerpt was taken from an iMasters discussion on the same subject.
Read this article here , it explains ways to use negative margins, showing common shapes, and errors too.