Stack Exchange sites use Markdown for questions and answers. Per the Markdown specification, intermixing HTML and Markdown markup is allowed, but not all the HTML tags are allowed, to avoid XSS.
Which HTML tags are allowed on Stack Exchange sites?
Stack Exchange sites use Markdown for questions and answers. Per the Markdown specification, intermixing HTML and Markdown markup is allowed, but not all the HTML tags are allowed, to avoid XSS.
Which HTML tags are allowed on Stack Exchange sites?
The Stack Exchange engine allows only the following safe, allowed subset of HTML tags.
Note: This table overflows to the right. Press your middle mouse button and wave your mouse left or right to scroll it, or use your laptop's trackpad (if applicable):
Tag | Title and Description | Preview | Markdown Equivalent |
---|---|---|---|
<a> |
Anchor Used to create hyperlinks. |
Stack Exchange | [Stack Exchange](https://meta.stackexchange.com) |
<b> |
Bold Formatting Used to bring the contents to the reader's attention. |
Stack Exchange Renders the same as <strong> . |
**this** syntax produces this <strong> text. |
<blockquote> |
Block Quotation Indicates that the enclosed text is an extended quotation. |
Stack Exchange |
> Stack Exchange |
<br> |
Line Break Produces a line break in text (carriage-return) |
Stack Exchange Stack Exchange |
Two spaces at the end of the first line:Stack Exchange |
<code> |
Inline Code Indicates that the text is a short fragment of computer code. |
Stack Exchange |
`Stack Exchange` |
<del> |
Deleted Text A range of text that has been deleted from a document. |
None on SE | |
<dd> <dl> <dt> |
Description List A description list. <dl> contains the list. Use <dt> for a Description Term and <dd> for the corresponding Description Details (description, definition, or value). |
|
None |
<em> |
Emphasis Marks text that has stress emphasis. |
Stack Exchange Renders same as <i> . |
*Stack Exchange* |
<h1> <h2> <h3> <h4> <h5> <h6> |
Section Heading<h1> –<h6> |
Stack ExchangeStack ExchangeStack ExchangeStack ExchangeStack ExchangeStack Exchange |
Stack Exchange # Stack Exchange |
<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. |
Stack Exchange Renders same as <em> . |
None, *this* syntax produces <em> |
<img> |
Image Embed Embeds an image into the document. |
![Stack Exchange Logo](https://i.sstatic.net/8ANhG.png) |
|
<kbd> |
Keyboard Input A span of inline text denoting textual user input from a keyboard, voice input, or any other text entry device. |
Stack Exchange | None |
<li> |
Used to represent an item in a list (<ol> or <ul> ). |
|
- List item |
<ol> |
Ordered List An ordered list of items—typically rendered as a numbered list. |
|
1. Step one |
<p> |
Paragraph. | Stack Exchange No visual changes, used to create explicit paragraphs |
Stack Exchange |
<pre> |
Preformatted Text Preformatted text which is to be presented exactly as written. |
Stack Exchange |
Stack Exchange ``` |
<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. |
Stack Exchange | **Stack Exchange** |
<sub> |
Subscript Inline text which should be displayed as subscript. |
TextStack Exchange | None |
<sup> |
Superscript Inline text which should be displayed as superscript. |
TextStack Exchange Because <small> is not on this list, many users use <sup> as an alternative. |
None |
<ul> |
Unordered List |
|
- An item |
<!-- language: [...] --> <!-- language-all: [...] --> |
Language comment Used to specify the syntax highlighting language for four-space indent and HTML code blocks or for the entire post, respectively, when used at the top of a block or the post. The former syntax is deprecated for four-space code blocks, but is still supported due to older posts using it. |
N/A | ```[language-name] |
<!-- begin snippet --> <!-- end snippet --> |
Stack Snippet comment Used to indicate the starting and ending points of a Stack Snippet embedded in the post. |
N/A | N/A |
<!-- summary: [...] --> |
Expanded user card summary comment Used in user profile descriptions to specify alternate text that should be rendered in user card hover popups on posts in lieu of the text in the bio itself. Can also be used to opt out of the popup while still having a bio (by using a summary that's shorter than 6 characters). |
N/A | <!-- summary: Short text here --> <!-- summary: abc --> |
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 may falsely recognize text between <
and >
characters as HTML, which may cause such text to be stripped out of the post; to prevent this, encode those characters as <
and >
.
Yes and no. While they (often) do work in the way you specify, that's not because they're officially supported by the system; they just happen to get removed as invalid HTML. Technically speaking, only the above comments used for special system features (syntax highlighting languages, Stack Snippets, and user card popup summaries) are supported. This fact leads to some quirks and limitations, such as that comments cannot contain the > character even though the HTML specification permits those characters in comments.
Attributes are only allowed on <img>
and <a>
. Other tags with attributes will be stripped.
<img>
The following attributes are allowed on the <img>
tag, in the order shown below.
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 like px
)height=""
(1–999; plain number without any extensions like px
; pay attention to order warning above)alt=""
title=""
<a>
Once again, attributes specified in reverse order to what is shown here will cause the tag to be stripped:
href=""
https://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, HTTPS, or FTP (e.g. javascript
, mailto
, or magnet
). Invalid href
s will strip the entire <a>
tag.*title=""
=
sign, and double quotes ""
.
<a href="...">
<a href="...">
<a href= "...">
<table>
element.* On Stack Overflow for Teams sites, mailto
links are allowed.