Allowed HTML Tags
The Stack Exchange engine allows only the following safe, whitelisted subset of HTML tags.
Press your middle mouse button and wave your mouse left or right to scroll the table, or use your laptop's trackpad (if applicable):
Tag | Title and Description | Preview | Markdown Equivalent |
---|---|---|---|
<a> |
Anchor Used to create hyperlinks. |
StackExchange | [StackExchange](https://meta.stackexchange.com) |
<b> |
Bring Attention To Used to draw the reader's attention to the contents, which are not otherwise granted special importance. |
StackExchange Renders the same as <strong> . |
None, **this** syntax produces <strong> |
<blockquote> |
Block Quotation Indicates that the enclosed text is an extended quotation. |
StackExchange |
> StackExchange |
<br> |
Line Break Produces a line break in text (carriage-return) |
StackExchange StackExchange |
Two spaces at the end of the first line:StackExchange |
<code> |
Inline Code Indicates that the text is a short fragment of computer code. |
StackExchange |
`StackExchange` |
<del> |
Deleted Text A range of text that has been deleted from a document. |
None on SE | |
<dd> |
Description Details Provides the description, definition, or value for the preceding term ( <dt> ) in a description list (<dl> ). |
|
None |
<dl> |
Description List A description list. |
|
None |
<dt> |
Description Term A term in a description or definition list. |
|
None |
<em> |
Emphasis Marks text that has stress emphasis. |
StackExchange Renders same as <i> . |
*StackExchange* |
<h1> <h2> <h3> <h4> <h5> <h6> |
Section Heading<h1> –<h6> |
StackExchangeStackExchangeStackExchangeStackExchangeStackExchangeStackExchange |
StackExchange # StackExchange |
<hr> |
Defines a thematic change in the content, usually via a horizontal line. | Must be an empty line before and after the dashes:--- |
|
<i> |
Idiomatic Text A range of text that is set off from the normal text for some reason. |
StackExchange Renders same as <em> . |
None, *this* syntax produces <em> |
<img> |
Image Embed Embeds an image into the document. |
![Picsum Image](http://picsum.photos/100) |
|
<kbd> |
Keyboard Input A span of inline text denoting textual user input from a keyboard, voice input, or any other text entry device. |
StackExchange | None |
<li> |
Used to represent an item in a list. |
|
- List item |
<ol> |
Ordered List An ordered list of items—typically rendered as a numbered list. |
|
1. Step one |
<p> |
Paragraph. | StackExchange No visual changes, used to create explicit paragraphs |
StackExchange |
<pre> |
Preformatted Text Preformatted text which is to be presented exactly as written. |
StackExchange |
StackExchange ``` |
<s> |
Renders text with a strikethrough, or a line through it. | None | |
|
Strikethrough is deprecated, use <del> or <s> instead. |
N/A | None |
<strong> |
Strong Importance Indicates that the contents have strong importance, seriousness, or urgency. Renders in bold type. |
StackExchange | **StackExchange** |
<sub> |
Subscript Inline text which should be displayed as subscript. |
TextStackExchange | None |
<sup> |
Superscript Inline text which should be displayed as superscript. |
TextStackExchange Because <small> is not on this list, many users use <sup> as an alternative. |
None |
<ul> |
Unordered List |
|
- An item + An item * An item |
<!-- […] --> |
Defines a comment, or text that will not be rendered in the post. | No true Markdown way |
Note that since we allow the above HTML tags, to have tags show up as text you need to escape the <
character. You can do this by marking it as code (with indentation or backticks as is done below) or by using the HTML entity <
.
Any tags not in the above list will be stripped out of the post. Do note that the sanitizer that strips out tags will recognize any text between <
and >
signs as HTML, and so any such text will be stripped out of the post; to prevent this, encode those signs as <
and >
. This does also mean that HTML comments cannot contain the > sign.
Allowed attributes
Attributes are only allowed on <img>
and <a>
. Other tags with attributes will be stripped.
Allowed attributes for <img>
The following attributes are allowed on the <img>
tag, in the order shown below. Note that the mobile theme enforces a maximum width
of 90%
, so specifying a height
might not scale the image proportionally on the mobile sites.
Attributes must be specified in this order. You may omit attributes you do not want to specify, but specifying a later attribute before an earlier one will strip the tag.
src=""
width=""
(1–999; plain number without any extensions likepx
)height=""
(1–999; plain number without any extensions likepx
; pay attention to order warning above)alt=""
title=""
Allowed attributes for <a>
Once again, attributes specified in reverse order to what is shown here will cause the tag to be stripped:
href=""
This attribute can only hold proper URL links, such ashttps://stackexchange.com/users/
, or relative or protocol-relative URL links such as/q/3122
or//stackexchange.com/users/
. They cannot hold other types of links, such as relative fragments (e.g.#3122
), or protocols other than HTTP or HTTPS (e.g.javascript
,ftp
, ormailto
). Invalidhref
s will strip the entire<a>
tag.title=""
Important Notes
- HTML tags unlisted above are stripped from the output. They may render in the client preview, but they will always be removed on the server.
- The tags must be entered exactly as shown in the list. Exactly one space must be present between attributes with no spaces between the attribute name,
=
sign, and double quotes""
.- Valid:
<a href="...">
- Invalid:
<a href="...">
- Invalid:
<a href= "...">
- Valid:
- While it is possible to make tables using Markdown syntax, we do not support the HTML
<table>
element.