Help:HTML in wikitext/pt

From Meta, a Wikimedia project coordination wiki

HTML Permitido[edit]

O seguinte elemento HTML é permitido no MediaWiki, a partir da versão 1.27:

Elemento Desde Notas
<abbr> 1.16
<b> 1.1
<bdi> 1.20
<bdo> 1.22
<big> 1.1 Deprecated in HTML5.
<blockquote> 1.1
<br> 1.1
<caption> 1.1
<center> 1.1 Deprecated in HTML5.
<cite> 1.1
<code> 1.1
<data> 1.21
<dd> 1.1
<del> 1.3
<dfn> 1.17
<div> 1.1
<dl> 1.1
<dt> 1.1
<em> 1.1
<font> 1.1 Deprecated in HTML5.
<h1> 1.1
<h2> 1.1
<h3> 1.1
<h4> 1.1
<h5> 1.1
<h6> 1.1
<hr> 1.1
<i> 1.1
<ins> 1.3
<kbd> 1.17
<li> 1.1
<link> 1.27 Microdata attributes only[n 1]
<mark> 1.21
<meta> 1.27 Microdata attributes only[n 1]
<ol> 1.1
<p> 1.1
<pre> 1.1
<q> 1.22
<rb> 1.1
<rp> 1.1
<rt> 1.1
<rtc> 1.24
<ruby> 1.1
<s> 1.1
<samp> 1.17
<small> 1.1
<span> 1.4
<strike> 1.1 Deprecated in HTML5.
<strong> 1.1
<sub> 1.1
<sup> 1.1
<table> 1.1
<td> 1.1
<th> 1.1
<time> 1.21
<tr> 1.1
<tt> 1.1 Deprecated in HTML5.
<u> 1.1
<ul> 1.1
<var> 1.1
<wbr> 1.22

For many HTML elements, more convenient wikitext code is available, see Help:Editing. On the other hand, HTML tags allow an id that can be referenced in one's user style css, and allows the tag to be used as link target.


For example, the anchor element <a> is not allowed, so the wikitext

<a href="http://meta.wikimedia.org/">Main Page</a>

is treated like the wikitext

&lt;a href="http://meta.wikimedia.org/"&gt;Main Page&lt;/a&gt;

and is therefore displayed as

<a href="http://meta.wikimedia.org/">Main Page</a>

which is unlikely to be what the editor intended. Instead of using the anchor element (<a>) the wiki markup for external reference is recommended (enclosed in square brackets with the URL separated from the contents by a single space):

[http://meta.wikimedia.org/ Main Page]

displays as:

Página Principal



The following excerpts from Sanitizer.php (1.29) additionally show which attributes are allowed.

      $htmlpairsStatic = array( # Tags that must be closed
        'b', 'bdi', 'del', 'i', 'ins', 'u', 'font', 'big', 'small', 'sub', 'sup', 'h1',
        'h2', 'h3', 'h4', 'h5', 'h6', 'cite', 'code', 'em', 's',
        'strike', 'strong', 'tt', 'var', 'div', 'center',
        'blockquote', 'ol', 'ul', 'dl', 'table', 'caption', 'pre',
        'ruby', 'rb', 'rp', 'rt', 'rtc', 'p', 'span', 'abbr', 'dfn',
        'kbd', 'samp', 'data', 'time', 'mark'
      );
      $htmlsingle = array(
        'br', 'wbr', 'hr', 'li', 'dt', 'dd', 'meta', 'link'
      );
      $htmlsingleonly = array( # Elements that cannot have close tags
        'br', 'wbr', 'hr', 'meta', 'link'
      );
      $htmlnest = array( # Tags that can be nested--??
        'table', 'tr', 'td', 'th', 'div', 'blockquote', 'ol', 'ul',
        'li', 'dl', 'dt', 'dd', 'font', 'big', 'small', 'sub', 'sup', 'span',
        'var', 'kbd', 'samp', 'em', 'strong', 'q', 'ruby', 'bdo'
      );
      $tabletags = array( # Can only appear inside table, we will close them
        'td', 'th', 'tr',
      );
      $htmllist = array( # Tags used by list
        'ul', 'ol',
      );
      $listtags = array( # Tags that can appear in a list
        'li',
      );
  1. a b <link> and <meta> are only permitted with Microdata attributes:[1] <link itemprop="..." href="..." /> and <meta itemprop="..." content="..." />.

Etiquetas[edit]

<span> is a generic inline text container.

<font> is a similar tag which is deprecated (should not be used) in favor of <span>.

Por exemplo:

a <font color="red">red</font> word.

produces the same result as

a <span style="color:red">red</span> word.

Consulte tamebém Template:Font size demo e Ajuda:Cor do Texto.

It's pointless to combine the legacy tag <font> with inline CSS; legacy browsers would ignore the CSS, while modern browsers support <span> (see above).

Note that in most cases, one can use a more descriptive tag, for instance, <strong> to indicate an important piece of text, or <em> (subject to the same things as strong) to indicate an emphasized piece of text.

This not only draws the user's attention to the text, but can also alert those who are using nonvisual browsers or have sight impairments, etc. to the fact that that is emphasized text.

Using <span> as a link target[edit]

The standard way of providing a named anchor as an invisible target (i.e. <a name="Foo">) doesn't work (since all <a> tags are converted), and an alternative suggested by the W3C, <hN id="Foo"></hN>, produces an "[Edit]" link.

However, <span id="Foo"> does produce a target that can be the destination of a link. Note that it doesn't work everywhere; for instance, in a table, it has to be inside a cell before some browsers will jump to it properly.

<div>[edit]

<div> is a generic block container. Rules:

  • <div> should be followed by a newline
  • </div> should be preceded by a newline
  • </div> followed by text on the same line, two newlines and text before <div> on the same line should be avoided (because the two newlines only produce a space)

Exemplo:

"----
o p<div>q</div>r s<div>t
u
v
x</div>y s<div>t
u
v
x</div>y z
----
"
→ "


o

p

q

r s

t

u v

x

y s

t

u v

x

y

z


" [2]

HTML comment[edit]

Using Template:T:

  • {{t}} gives start-pqr-end [3]
  • "{{subst:xpd|t}}" gives the wikitext "<!--t-->start-pqr-end", producing HTML code without the comment.

The "Remove comments" option of ExpandTemplates selects whether comments are removed, not just in the final result but throughout the expansion process. This affects the result of parser functions: a comment in the expression of #expr or in the condition of #ifexpr gives an error message unless "Remove comments" is on, and comments affect #if and ifeq.

Exemplo:

Texto Wiki:


{{#expr:<!--p-->3}}

{{#ifeq:<!--p-->3|3|1|0}}

{{#if:<!--p-->|1|0}}

Result of normal expansion, and of ExpandTemplates with "Remove comments" on:


3

1

0


Result of full substitution, and of ExpandTemplates with "Remove comments" off:


Expression error: Unrecognised punctuation character "?"

0

1


Therefore it is typically better to avoid comments in these places, and to put the comment before or after the parser function.

In the case of nested parser functions, to avoid having to put the comments outside the whole, an alternative is {{void|comment}}. In the case of substitution of the parser function, "void" has to be substituted too, e.g. in a template allowing multi-level substitution we can put {{{{{subst1|}}}#expr:3*{{{1}}} {{{{{subst1|}}}void| multiply by 3 }}}}.

Another alternative is making the comment the name of a parameter (in the likely case that it is unused), with the empty string as default, e.g. {{{ multiply by 3 |}}} or, to recognize the intention, use pseudo comment tags: {{{<!- multiply by 3 ->|}}}, or real ones, if the empty string is not used as parameter: {{{<!-- multiply by 3 -->|}}}.

See also Template:T comment.

Atributos[edit]

Most tags can have a style attribute. For example

<div style="font-size:80%">
This is <span style="color:red">red</span> text.
</div>

produces:

This is red text.


Most tags can have classes and IDs. They can be used in conjunction with stylesheets to give a piece of text a descriptive class (or unique identifier) and to refer to that in a stylesheet.

Classes and IDs can also be used by Javascript code.


Another attribute example is title, for example used in {{H:title}} template: note the hover box over "20000 ft"

"a height of 20000 ft above sea level"


Etiqeutas com efeito especial[edit]

Pre[edit]

<pre> tags work as the combination of <nowiki> and the standard HTML <pre> tag: the content will preformatted, and it will not be parsed, but shown as in the wikitext source. If you want preformatted but parsed text, use a space in the beginning of the line instead. For example,

<pre>This word is <b>bold</b>.</pre>
  This word is <b>bold</b>.

will render as

This word is <b>bold</b>.
This word is bold.

Comentários[edit]

HTML comments in the wikitext (<!-- ... -->) will not appear in the HTML code at all.

Cabeçalhos[edit]

Headers (<h1>...<h6>) will be treated in a similar way as wikicode headers:

sample header

Note that it appears in the table of contents and has an accompanying edit link. There are some minor differences though: editing such a section won't prefill the edit summary, and the browser won't jump to the beginning of the section when saving the page. Thus, you should use the wikitext equivalents instead.

Exceções[edit]

In some pages in the MediaWiki namespace (typically the short messages like button labels) HTML does not work, and e.g. <span id=abc> produces the HTML &lt;span id=abc&gt; rendered by the browser as <span id=abc>. Some others are interpreted as pure HTML (thus any tag can be used, but wikicode won't be transformed to HTML).

User CSS and JS pages (see Help:User style) are interpreted as if inside a <pre> block. From MW 1.11 this also goes for sitewide CSS/JS; in earlier versions, you have to manually add /*<pre>*/ to the beginning and /*</pre>*/ to the end of those pages to avoid strange rendering.

Hiperligações Externas[edit]

Hiperligações para outras páginas de ajuda[edit]

Conteúdos da Ajuda
Meta · Wikinotícias · Wikipédia · Wikiqcitações · Wikcionário · Commons: · Wikidados · MediaWiki · Wikilivros · Wikisource · MediaWiki: Manual · Google
Versões desta página de ajuda (para outros idiomas, veja mais)
O que interliga aqui no Meta ou de Meta · Wikipédia · MediaWiki
Leitura
Ir · Pesquisar · Espaço Nominal · Nome da Página · Secção · Backlinks · Redirecionamentos · Categoria · Página da Imagem · Páginas Especiais · Versão Imprimível
Monitorizar alterações
Alterações recentes (otimizadas) | Alterações relacionadas · Páginas de vigia · Diferenças · Histórico da página · Resumo da edição · Contribuições do utilizador · Edição menor · Edição patrulhada
Registar e preferências
Iniciar Sessão · Preferências · Estilo do Utilizador
Edição
Iniciar uma nova página · Edição avançada · Editar as «Perguntas Mais Frequentes» · Exportar · Importar · Atalhos · Conflito de Edição · Tamanho da Página
Referenciar
Hiperligações · URL · Hiperligações associadas · Interligar Interwiki · Notas de Rodapé
Estilo e formatação
Exemplos de Texto da Wiki · CSS · Cartão de referência · HTML no Texto da Wiki · Fórmula · Lista · Tabela · Ordenação · Cores · Envios de Ficheiros e Imagens
Corrigir erros
Mostra Pré-visualização · Testes · Reverter Edições
Funionamento avançado
Expansão · Modelo · Modelos Avançados · Função do Analisador · Parâmetro Predefinido · Variável · Mensagem do Sistema · Substituição · Array · Calculo · Integrar Página
Outros
Carateres Especiais · Renomear (mover) uma página · Preparar uma página para tradução · Página de Discussão · Assinaturas · Página de Testes (Sandbox) · Problemas Legais para os Editores
Other languages: