Resumo
HTML texto preformatado (<pre>) é a tag utilizada para representar texto pré-formatado. Um texto dentro desse elemento é tipicamente exibido em uma fonte não proporcional da mesma maneira em que o texto original foi disposto no arquivo. Espaços em branco são mantidos no texto da mesma forma em que este foi digitado.
Content categories Flow content, palpable content.
- Conteúdo permitido Phrasing content.
- Tag omission None, both the starting and ending tag are mandatory.
- Elementos pai permitidos Any element that accepts flow content.
- interface DOM
HTMLPreElement
Atributos
Esse elemento apenas inclui atributos globais.
This element only includes the global attributes.
cols
- Contains the preferred count of characters that a line should have. It was a non-standard synonym of
width
. To achieve such an effect, use CSS styling instead. width
- Contains the preferred count of characters that a line should have. Though technically still implemented, this attribute has no visual effect; to achieve such an effect, use CSS styling instead.
wrap
- Is a hint indicating how the overflow must happen. In modern browser this hint is ignored and no visual effect results in its present; to achieve such an effect, use CSS styling instead.
Exemplos
<!-- Um exemplo de código css -->
<pre>
body {
color:red;
}
</pre>
Resultado
body { color:red; }
Especificações
Especificação | Status | Comentário |
---|---|---|
HTML Living Standard The definition of '<pre>' in that specification. |
Padrão em tempo real | Nenhuma mudança significante na HTML Living Standard |
HTML5 The definition of '<pre>' in that specification. |
Recomendação | Nenhuma mudança significante na HTML 4.01 Specification |
HTML 4.01 Specification The definition of '<dl>' in that specification. |
Recomendação | Atributto cols obsoleto |
Compatibilidade de navegador
Estamos convertendo nossos dados de compatibilidade para o formato JSON.
Esta tabela de compatibilidade ainda usa o formato antigo,
pois ainda não convertemos os dados que ela contém.
Descubra como você pode ajudar!
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|
Basic support | 1.0 | 1.0 (1.7 or earlier) | (Yes) | (Yes) | (Yes) |
width |
(Yes) No layout effect |
1.0 (1.7 or earlier) Layout effect removed in 29.0 (29.0) |
(Yes) No layout effect |
(Yes) No layout effect |
(Yes) No layout effect |
cols |
Não suportado | 1.0 (1.7 or earlier) Removed in 29.0 (29.0) |
Não suportado | Não suportado | Não suportado |
wrap |
? | 1.0 (1.7 or earlier) | ? | ? | ? |
Feature | Android | Firefox Mobile (Gecko) | IE Phone | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|
Basic support | (Yes) | 1.0 (1.0) | (Yes) | (Yes) | (Yes) |
width |
? | 1.0 (1.0) Layout effect removed in 29.0 (29.0) |
? | ? | ? |
cols |
Não suportado | 1.0 (1.0) | Não suportado | Não suportado | Não suportado |
wrap |
? | 1.0 (1.0) | ? | ? | ? |
Veja mais
- CSS:
white-space
,word-break