What is meta? ×
Meta Stack Exchange is where users like you discuss bugs, features, and support issues that affect the software powering all 122 Stack Exchange communities.

The Stack Overflow site engine, as you know, uses Markdown for questions and answers. Per the Markdown spec, you are allowed to freely intermix HTML and Markdown tags.

However, we do not allow all HTML tags, as that would be an XSS paradise. To that end, the Stack Overflow engine allows only the following safe, whitelisted subset of HTML tags:

<a>
<b>
<blockquote>
<code>
<del>
<dd>
<dl>
<dt>
<em>
<h1>, <h2>, <h3>
<i>
<img>
<kbd>
<li>
<ol>
<p>
<pre>
<s>
<sup>
<sub>
<strong>
<strike>
<ul>
<br/>
<hr/>

The following attributes are allowed on the <img> tag:

src=""
width="" (up to 999)
height="" (up to 999)
alt=""
title=""

The following attributes are allowed on the <a> tag:

href=""
title=""

HTML tags not on this list are stripped from the output. They may render in the client preview but they will always be removed on the server.You must enter the tags exactly as shown. Any deviation from this list (adding extra spaces, using single quote or no quotes, etc) means the tag will be stripped.

We do not and will not allow table tags -- sorry. This is intentional and by design. If you need a quick and dirty "table", use <pre> and ASCII layout.

However, if there's some other (safe!) tag you think we should allow, I am open to suggestions.

share|improve this question
4  
A couple of people have sort of hinted at this, but there is limited markup available for comments. There is more information on this here - meta.stackexchange.com/questions/63286/… - but a really useful tip is to click on the help link under Add Comment, as this will provide you with a full list. This is a great posts/wiki by the way. –  Aaron Newton Dec 5 '11 at 21:48
    
How would I add an image that has surrounding floating text? –  rubo77 Apr 22 '13 at 18:43
    
@rubo77 considering you can use div or span, I'd say you can't. You could try using img tags directly with style="float:right;margin:5px;", but I don't know if it would work. –  Cole Johnson Aug 23 '13 at 5:34
    
No (see the first answer) > the img tag only allows alt, title, width, height and src –  rubo77 Aug 23 '13 at 7:22
    
What about <em>this</em> ? –  Nicolas Barbulesco Jan 3 at 8:56
    
@NicolasBarbulesco what about it? It's listed below so it's allowed. –  Shadow Wizard Mar 13 at 12:12
    
@ShadowWizard — If so, why does it <em>fail</em> to <em>work</em> in my comments here ? –  Nicolas Barbulesco Mar 15 at 15:19
    
@NicolasBarbulesco because comments support only very limited subset of markdown, which does not contain any tags at all. See this for details. –  Shadow Wizard Mar 15 at 21:24
    
Would it be wise, to allow trusted websites such as JS fiddle, to paste their iframe? e.g: <iframe width="100%" height="300" src="http://jsfiddle.net/fD5u3/embedded/" allowfullscreen="allowfullscreen" frameborder="0"></iframe> –  Val Mar 24 at 21:43
add comment

1 Answer

Allowed HTML Tags

The Stack Exchange engine allows only the following safe, whitelisted subset of HTML tags:

<a>              - hyperlink.
<b>              - bold, use as last resort <h1>-<h3>, <em>, and <strong> are 
                   preferred.
<blockquote>     - specifies a section that is quoted from another source.
<code>           - defines a piece of computer code.
<del>            - delete, used to indicate modifications.
<dd>             - describes the item in a <dl> description list.
<dl>             - description list.
<dt>             - title of an item in a <dl> description list.
<em>             - emphasized.
<h1>, <h2>, <h3> - headings.
<i>              - italic.
<img>            - specifies an image tag.
<kbd>            - shows keyboard input.
<li>             - list item in an ordered list <ol> or an unordered list <ul>.
<ol>             - ordered list.
<p>              - paragraph.
<pre>            - pre-element displayed in a fixed width font and and 
                   unchanged line breaks.
<s>              - strikethrough.
<sup>            - superscript text appears 1/2 character above the baseline 
                   used for footnotes and other formatting.
<sub>            - subscript appears 1/2 character below the baseline.
<strong>         - defines important text.
<strike>         - strikethrough is deprecated, use <del> instead.
<ul>             - unordered list.
<br>             - line break.
<hr>             - defines a thematic change in the content, usually via a 
                   horizontal line.

Note that since we allow the above HTML tags, to have tags show up as text you need to escape the < character. You can escape '<' by marking it as code (with indentation or backticks as is done below) or by using the HTML entity &lt;

Allowed Attributes

img Attributes

The following attributes are allowed on the <img> tag, but 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.

The attribute order is important! Using a different order (e.g., height before width) will strip the tag!

src=""
width="" (up to 999; do not include the 'px' extension)
height="" (up to 999; do not include the 'px' extension; see note above)
alt=""
title=""

a Attributes

The following attributes are allowed on the <a> tag:

href=""
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.

  • You must enter the tags exactly as shown. Any deviation from this list—adding extra spaces, using single quote or no quotes, etc.—means the tag will be stripped.

  • We do not (and will not) allow <table> tags. Sorry. This is intentional and by design. If you need a quick and dirty "table", use <pre> and ASCII layout.
share
locked by random Mar 22 at 12:36
comments disabled on deleted / locked posts

This post has been locked due to the high amount of off-topic comments generated. For extended discussions, please use chat.

You must log in to answer this question.

protected by Community Jul 31 '11 at 11:38

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged .