Jump to content

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

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

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

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

Разрешённые теги и атрибуты HTML в ПО MediaWiki
Тег Значение Разрешённые атрибуты Разрешён с… Примечания
‎<abbr> Сокращение common attributes 1.16
‎<b> Привлечение внимания common attributes 1.1 Вики-разметка: три одиночные кавычки, например, Обратите внимание на '''этот текст'''.
‎<bdi> Bidirectional isolate common attributes 1.20
‎<bdo> Bidirectional text override common attributes 1.22
‎<big> Make text bigger common attributes 1.1 ‎<big> is deprecated in HTML, but not in wikitext (T154067)
‎<blockquote> Block quotation common attributes + cite 1.1
‎<br> Line break common attributes + clear 1.1
‎<caption> Table caption common attributes + align 1.1
‎<cite> Citation, i.e. reference to a cited creative work. common attributes 1.1
‎<code> Inline computer code common attributes 1.1
‎<col> common attributes + span
‎<colgroup> common attributes + span
‎<data> Data, linked to machine-readable translation through value attribute. common attributes + value 1.21
‎<dd> Description details for a description term element, inside a description list. common attributes 1.1 Wikitext: : starting the line, respectively for description list details.
‎<del> Удалённый текст common attributes + cite, datetime 1.3
‎<dfn> Definition. Wrap a term/phrase which is being defined. common attributes 1.17
‎<div> Content division, to apply CSS formatting to a block. common attributes + align 1.1
‎<dl> Description list. common attributes 1.1
‎<dt> Description term, inside a description list. common attributes 1.1 Wikitext: ; starting the line, respectively for description list term.
‎<em> Emphasis common attributes 1.1
‎<h1> Заголовок раздела — уровни от 1 до 6. 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 + width 1.1 Вики-разметка: 4 или более дефисов (----) с начала строки.
‎<i> Idiomatic text common attributes 1.1 Wikitext: two single quotes, e.g. ''idiomatic text''.
‎<ins> Added text common attributes + cite, datetime 1.3
‎<kbd> Keyboard input common attributes 1.17
‎<li> Пункт списка 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 1.21
‎<meta> Метаданные itemprop, content 1.27 Must have itemprop and content attributes set.[1]
‎<ol> Ordered list common attributes + type, start, reversed 1.1
‎<p> Параграф common attributes + align 1.1 Викитекст: текст между пустыми строками.
‎<pre> Preformatted text 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 + cite 1.22
‎<rp> Ruby fallback parenthesis common attributes 1.1
‎<rt> Ruby text: annotation rendered near the base text. Inside a ruby tag. common attributes 1.1
‎<ruby> Ruby annotation. Encloses rt and rp. common attributes 1.1
‎<s> Strikethrough, for no longer accurate or relevant text. common attributes 1.1
‎<samp> Sample output, inline ouput text of a computer program. common attributes 1.17
‎<small> Side comment. common attributes 1.1
‎<span> Content span, to apply CSS formatting to an inline text. common attributes 1.4
‎<strong> Strong importance. common attributes 1.1
‎<sub> Subscript common attributes 1.1
‎<sup> Superscript common attributes 1.1
‎<table> Table, for tabular data. 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 + 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 + abbr, axis, headers, scope, rowspan, colspan, nowrap, width, height, bgcolor, align, valign 1.1 Wikitext: see help page about tables.
‎<time> Дата/время common attributes + datetime 1.21
‎<tr> Table row, inside a table tag. common attributes + bgcolor, align, valign 1.1 Wikitext: see help page about tables.
‎<u> Unarticulated annotation. common attributes 1.1
‎<ul> Неупорядоченный список. common attributes + type 1.1
‎<var> Переменная common attributes 1.1
‎<wbr> Возможность для разрыва строки common attributes 1.22

Общие атрибуты

Для почти всех тегов, перечисленных в таблице выше (кроме 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.

Примечания