--- title: margin-top slug: Web/CSS/margin-top translation_of: Web/CSS/margin-top ---
A propriedade CSS
margin-top de um elemento indica o espaço acima do elemento. Valores negativos são aceitos.
Essa propriedade não tem efeito em elementos non-replaced inline elements, como {{HTMLElement("tt")}} ou {{HTMLElement("span")}}.
{{cssinfo}}
/* Valores <length> */ margin-top: 10px; /* An absolute length */ margin-top: 1em; /* A length relative to the text size */ margin-top: 5%; /* A margin relative to the nearest block container's width */ /* Valores padrão */ margin-top: auto; /* Valores globais */ margin-top: inherit; margin-top: initial; margin-top: unset;
<length><porcentagem>auto.content { margin-top: 5%; }
.sidebox { margin-top: 10px; }
.logo { margin-top: -5px; }
#footer { margin-top: 1em; }
| Especificação | Status | Comentário |
|---|---|---|
| {{SpecName('CSS3 Box', '#the-margin', 'margin-top')}} | {{Spec2('CSS3 Box')}} | Sem mudança significativa. |
| {{SpecName('CSS3 Transitions', '#animatable-css', 'margin-top')}} | {{Spec2('CSS3 Transitions')}} | Define margin-top como animável. |
| {{SpecName('CSS2.1', 'box.html#margin-properties', 'margin-top')}} | {{Spec2('CSS2.1')}} | Remove esse efeito em elementos inline. |
| {{SpecName('CSS1', '#margin-top', 'margin-top')}} | {{Spec2('CSS1')}} | Definição inicial. |
{{CompatibilityTable()}}
| Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
|---|---|---|---|---|---|
| Suporte básico | 1.0 | {{CompatGeckoDesktop("1")}} | 3.0 | 3.5 | 1.0 (85) |
Valor auto |
1.0 | {{CompatGeckoDesktop("1")}} | 6.0 (strict mode) | 3.5 | 1.0 (85) |
| Feature | Android | Firefox Mobile (Gecko) | IE Phone | Opera Mobile | Safari Mobile |
|---|---|---|---|---|---|
| Suporte básico | 1.0 | {{CompatGeckoMobile("1")}} | 6.0 | 6.0 | 1.0 |