Jump to content

Справка:HTML в вики-разметке

From mediawiki.org
This page is a translated version of the page Help:HTML in wikitext and the translation is 52% complete.
PD Примечание: Редактируя эту страницу, вы соглашаетесь на передачу своего вклада по лицензии CC0.
Подробнее — в проекте Помощь с общественным достоянием.
PD

Движок MediaWiki способен обработать некоторые теги HTML в разметке. Скобки у других тегов экранируются, и такие теги не интерпретируются, а отображаются как текст.

Разрешённые теги и атрибуты HTML

Разрешённые теги и атрибуты HTML в ПО MediaWiki
Тег Значение Разрешённые атрибуты Разрешён с… Примечания
‎<abbr> Сокращение [[#Common attributes|Common attributes]] 1.16
‎<b> Привлечение внимания [[#Common attributes|Common attributes]] 1.1 Вики-разметка: три одиночные кавычки, например, Обратите внимание на '''этот текст'''.
‎<bdi> Bidirectional isolate [[#Common attributes|Common attributes]] 1.20
‎<bdo> Bidirectional text override [[#Common attributes|Common attributes]] 1.22
‎<big> Make text bigger [[#Common attributes|Common attributes]] 1.1 ‎<big> is deprecated in HTML, but not in wikitext (T154067)
‎<blockquote> Block quotation [[#Common attributes|Common attributes]] + cite 1.1
‎<br> Line break [[#Common attributes|Common attributes]] + clear 1.1
‎<caption> Table caption [[#Common attributes|Common attributes]] + align 1.1
‎<cite> Citation, i.e. reference to a cited creative work. [[#Common attributes|Common attributes]] 1.1
‎<code> Inline computer code [[#Common attributes|Common attributes]] 1.1
‎<col> [[#Common attributes|Common attributes]] + span
‎<colgroup> [[#Common attributes|Common attributes]] + span
‎<data> Data, linked to machine-readable translation through value attribute. [[#Common attributes|Common attributes]] + value 1.21
‎<dd> Description details for a description term element, inside a description list. [[#Common attributes|Common attributes]] 1.1 Wikitext: : starting the line, respectively for description list details.
‎<del> Удалённый текст [[#Common attributes|Common attributes]] + cite, datetime 1.3
‎<dfn> Definition. Wrap a term/phrase which is being defined. [[#Common attributes|Common attributes]] 1.17
‎<div> Content division, to apply CSS formatting to a block. [[#Common attributes|Common attributes]] + align 1.1
‎<dl> Description list. [[#Common attributes|Common attributes]] 1.1
‎<dt> Description term, inside a description list. [[#Common attributes|Common attributes]] 1.1 Wikitext: ; starting the line, respectively for description list term.
‎<em> Emphasis [[#Common attributes|Common attributes]] 1.1
‎<h1> Заголовок раздела — уровни от 1 до 6. [[#Common attributes|Common attributes]] + align 1.1 Wikitext: pairs of equal signs (see help about formatting).

Note when you edit a section headed by an HTML heading, the edit summary will not be prefilled.

‎<hr> Тематический разрыв [[#Common attributes|Common attributes]] + width 1.1 Вики-разметка: 4 или более дефисов (----) с начала строки.
‎<i> Idiomatic text [[#Common attributes|Common attributes]] 1.1 Wikitext: two single quotes, e.g. ''idiomatic text''.
‎<ins> Added text [[#Common attributes|Common attributes]] + cite, datetime 1.3
‎<kbd> Keyboard input [[#Common attributes|Common attributes]] 1.17
‎<li> Пункт списка [[#Common attributes|Common attributes]] + type, value 1.1 Wikitext: # or * starting the line, respectively for ordered list and unordered list.
‎<link> External resource link itemprop, href, title 1.27 Must have itemprop and href attributes set.[1] Excludes most values for rel, including the stylesheet value.
‎<mark> Marked or highlighted text. [[#Common attributes|Common attributes]] 1.21
‎<meta> Метаданные itemprop, content 1.27 Must have itemprop and content attributes set.[1]
‎<ol> Ordered list [[#Common attributes|Common attributes]] + type, start, reversed 1.1
‎<p> Параграф [[#Common attributes|Common attributes]] + align 1.1 Викитекст: текст между пустыми строками.
‎<pre> Preformatted text [[#Common attributes|Common attributes]] + width 1.1 Content is not parsed, as in a ‎<nowiki> tag.

Wikitext: line starting with a blank space, i.e.  preformatted text.

‎<q> Inline quotation [[#Common attributes|Common attributes]] + cite 1.22
‎<rp> Ruby fallback parenthesis [[#Common attributes|Common attributes]] 1.1
‎<rt> Ruby text: annotation rendered near the base text. Inside a ruby tag. [[#Common attributes|Common attributes]] 1.1
‎<ruby> Ruby annotation. Encloses rt and rp. [[#Common attributes|Common attributes]] 1.1
‎<s> Strikethrough, for no longer accurate or relevant text. [[#Common attributes|Common attributes]] 1.1
‎<samp> Sample output, inline ouput text of a computer program. [[#Common attributes|Common attributes]] 1.17
‎<small> Side comment. [[#Common attributes|Common attributes]] 1.1
‎<span> Content span, to apply CSS formatting to an inline text. [[#Common attributes|Common attributes]] 1.4
‎<strong> Strong importance. [[#Common attributes|Common attributes]] 1.1
‎<sub> Subscript [[#Common attributes|Common attributes]] 1.1
‎<sup> Superscript [[#Common attributes|Common attributes]] 1.1
‎<table> Table, for tabular data. [[#Common attributes|Common attributes]] + summary, width, border, frame, rules, cellspacing, cellpadding, align, bgcolor 1.1 Wikitext: see help page about tables.
‎<td> Table data cell, inside a tr tag. [[#Common attributes|Common attributes]] + abbr, axis, headers, scope, rowspan, colspan, nowrap, width, height, bgcolor, align, valign 1.1 Wikitext: see help page about tables.
‎<th> Table header cell, inside a tr tag [[#Common attributes|Common attributes]] + abbr, axis, headers, scope, rowspan, colspan, nowrap, width, height, bgcolor, align, valign 1.1 Wikitext: see help page about tables.
‎<time> Дата/время [[#Common attributes|Common attributes]] + datetime 1.21
‎<tr> Table row, inside a table tag. [[#Common attributes|Common attributes]] + bgcolor, align, valign 1.1 Wikitext: see help page about tables.
‎<u> Unarticulated annotation. [[#Common attributes|Common attributes]] 1.1
‎<ul> Неупорядоченный список. [[#Common attributes|Common attributes]] + type 1.1
‎<var> Переменная [[#Common attributes|Common attributes]] 1.1
‎<wbr> Возможность для разрыва строки [[#Common attributes|Common attributes]] 1.22

Common attributes

Для почти всех тегов, перечисленных в таблице выше (кроме meta и link) допускаются следующие атрибуты:

  • HTML
    • id
    • class
    • style
    • lang
    • dir
    • title
    • tabindex
  • WAI-ARIA
    • aria-describedby
    • aria-flowto
    • aria-hidden
    • aria-label
    • aria-labelledby
    • aria-level
    • aria-owns
    • role
  • RDFa
    • about
    • property
    • resource
    • datatype
    • typeof
  • Microdata
    • itemid
    • itemprop
    • itemref
    • itemscope
    • itemtype

Устаревшие теги

Теги ниже обрабатываются MediaWiki, но признаны устаревшимы в HTML 5. Их стоит заменить на что-либо из тегов выше. Вы можете добавить атрибут style, чтобы воспроизвести их требуемое отображение.

Устаревшите теги HTML в MediaWiki
Тег Разрешён с… Выбрасывает ошибку анализатора? Примечания
‎<center> 1.1 Да
‎<font> 1.1 Да
‎<rb> 1.1 Нет
‎<rtc> 1.24 Нет
‎<strike> 1.1 Да
‎<tt> 1.1 Да


Случаи использования

Якорь

Для создания якоря, на который можно было бы ссылаться, вы можете использовать любой HTML-тег с атрибутом id.

Например, <span id="note2"></span> позволит вам создать ссылку на своё положение на странице путём использования [[#note2|См. примечение]].

CSS-форматирование

С атрибутом style

Использование тега HTML вместо равносильной вики-разметки позволяет вам добавить атрибут style для определения его пользовательского отображения через язык CSS.

С атрибутами class и id

Благодаря TemplateStyles вы можете добавить к документу пользовательские таблицы стилей. Таким образом добавление атрибутов class или id будет полезно, если вы хотите каспомизировать их внешний вид.

Перезаписываемый синтакс HTML

HTML-комментарии

Вики-разметка использует синтакс комментариев HTML для своих собственных комментариев. Они игнорируются парсером и не включаются в выходной HTML — даже как HTML-комментарии.

<!-- Это текст комментария в вики-разметке. После сохранения он будет оставлен в исходном коде разметки, но не отображён и не отрендерен в исходном коде HTML. -->

Тег Pre

Содержимое тега pre не обрабатывается, как в теге ‎<nowiki>.

Вы должны использовать эквивалентный синтаксис вики-разметки, чтобы разрешить анализ содержимого. Т.е. начинать каждую строку с пробела:

 Некоторый предварительно отформатированный текст, который может содержать вики-разметку; так например, ''этот выделенный текст'' будет интерпретирован.
 Другая строка.

чтобы вывести:

Некоторый предварительно отформатированный текст, который может содержать вики-разметку; так например, этот выделенный текст будет интерпретирован.
Другая строка.

См. также

  • Help:Extension:Linter – Помощь по расширению Linter, которое замечает проблемы HTML на страницах.
  • Ограничения HTML – Информация об ограничениях MediaWiki для HTML-содержимого и расширениях, которые дополняют его поддержку.
  • Manual:$wgRawHtml – Расширения, позволяющие использовать дополнительный HTML.

Примечания