What Works (with Examples)
A definitive reference for using HTML inside GitHub Flavored Markdown (GFM) documents on GitHub.
Includes allowed tags, examples, best practices, and references.
<script>, <style>, <iframe>, <embed>, <object>class, and id are stripped by sanitizationhref, src, title, alt, width, height, align, target, lang, itemscope, itemtype, itemprophttp, https, mailto, and relative (./file.md)<details><summary> supported across README/issues/PRsPrefer Markdown for most formatting. Use HTML only when Markdown canβt express your intent (e.g., collapsibles, ruby annotations, complex tables, keyboard keys).
<h1>Main Title</h1>
<h2>Section</h2>
For example:
(Prefer # Markdown headings for readability; HTML headings are fine when needed inline.)
<b>Bold</b> <strong>Strong</strong>
<i>Italic</i> <em>Emphasis</em>
<s>Strike</s> <del>Deleted</del>
<ins>Inserted</ins>
<mark>Highlight</mark>
For example:
Bold, Strong, Italic, Emphasis, Strike, Deleted, Inserted, Highlight
E = mc<sup>2</sup>, H<sub>2</sub>O
For example:
E = mc2, H2O
<code>npm install</code>
<pre>
line 1
line 2
</pre>
<kbd>Ctrl</kbd> + <kbd>C</kbd>
<samp>output sample</samp>
<var>x</var>
<tt>Monospace text</tt>
For example:
npm install
line 1 line 2
Ctrl + C
output sample
x
Monospace text
<q cite="https://example.com">Inline quote</q>
<blockquote cite="https://example.com">
Block quote example with citation.
</blockquote>
For example:
Inline quote
Block quote example with citation.
<a href="https://github.com" title="GitHub" target="_blank">GitHub</a>
For example:
GitHub
<img src="https://placehold.co/120x80.png" alt="Placeholder" width="120" height="80" title="Example image">
For example:

<ol>
<li>First</li>
<li>Second</li>
</ol>
<ul>
<li>A</li>
<li>B</li>
</ul>
For example:
<table>
<thead>
<tr><th>Col1</th><th>Col2</th><th>Col3</th></tr>
</thead>
<tbody>
<tr><td rowspan="2">Rowspan</td><td>A</td><td>B</td></tr>
<tr><td colspan="2">Colspan example</td></tr>
</tbody>
<tfoot><tr><td colspan="3">Footer</td></tr></tfoot>
</table>
For example:
| Col1 | Col2 | Col3 |
|---|---|---|
| Rowspan | A | B |
| Colspan example | ||
| Footer | ||
<dl>
<dt>Term</dt>
<dd>Definition</dd>
</dl>
For example:
<hr>
Line 1<br>Line 2
For example:
Line 1
Line 2
<div align="center">
<p>Centered paragraph</p>
<img src="https://placehold.co/80x80.png" alt="icon">
</div>
For example:
Centered paragraph

<details>
<summary>Click to expand</summary>
You can include **Markdown**, lists, code blocks, and images inside.
```bash
echo "Hello"
</details>
For example:
<details><summary>Click to expand</summary>
You can include **Markdown**, lists, code blocks, and images inside.
```bash
echo "Hello"
</details>
Tips:
<summary> for Markdown to render inside.</details> for consistency.<ruby>ζΌ’<rt>hΓ n</rt></ruby>
<ruby>ζΌ’<rp>(</rp><rt>hΓ n</rt><rp>)</rp></ruby>
For example:
ζΌ’
ζΌ’
<script>, <style>, <iframe>, <embed>, <object> β strippedstyle="...") and class/id β strippedjavascript:, vbscript:) β stripped<video> and <audio> not consistently supported| Tag | Allowed? | Attributes | Notes |
|---|---|---|---|
<a> |
β | href, title, target | Safe schemes only |
<img> |
β | src, alt, width, height, title | style/class stripped |
<details>/<summary> |
β | open | Great for collapsibles |
<sup>/<sub> |
β | β | Good for math, chemistry |
<kbd>/<code>/<pre> |
β | β | For code & input |
<table> + children |
β | colspan, rowspan, align | Complex tables work |
<div> |
β | align, itemscope, itemtype | style/class ignored |
<ruby>/<rt>/<rp> |
β | β | East Asian annotations |
<script>/<iframe>/<style> |
β | β | Removed |
<details> content improve parsingSee CONTRIBUTING.md for guidelines.
By contributing, you agree your contributions are licensed under CC BY 4.0.
Creative Commons Attribution 4.0 International (CC BY 4.0)
You are free to share and adapt, including commercial use, with attribution.
See: https://creativecommons.org/licenses/by/4.0/
Last Verified: 2025β09β11 (America/Chicago)
Confidence: High