HTML-Tags-Supported-in-GitHub-Flavored-Markdown-Documents

HTML Tags You Can Use in Markdown Documents

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.


πŸ“š Table of Contents


🚦 Key Rules

Prefer Markdown for most formatting. Use HTML only when Markdown can’t express your intent (e.g., collapsibles, ruby annotations, complex tables, keyboard keys).


πŸ“‘ Headings

<h1>Main Title</h1>
<h2>Section</h2>

For example:

Main Title

Section

(Prefer # Markdown headings for readability; HTML headings are fine when needed inline.)


✍ Text Emphasis & Edits

<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


πŸ”’ Superscript & Subscript

E = mc<sup>2</sup>, H<sub>2</sub>O

For example:
E = mc2, H2O


⌨ Code & Preformatted

<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


πŸ’¬ Quotes

<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


πŸ–Ό Images

<img src="https://placehold.co/120x80.png" alt="Placeholder" width="120" height="80" title="Example image">

For example:
Placeholder


πŸ“‹ Lists

<ol>
  <li>First</li>
  <li>Second</li>
</ol>

<ul>
  <li>A</li>
  <li>B</li>
</ul>

For example:

  1. First
  2. Second

πŸ“Š Tables

<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:

Col1Col2Col3
RowspanAB
Colspan example
Footer

πŸ“– Definition Lists

<dl>
  <dt>Term</dt>
  <dd>Definition</dd>
</dl>

For example:

Term
Definition

πŸ“ Horizontal Rules & Line Breaks

<hr>
Line 1<br>Line 2

For example:


Line 1
Line 2


πŸ“¦ Block Containers & Alignment

<div align="center">
  <p>Centered paragraph</p>
  <img src="https://placehold.co/80x80.png" alt="icon">
</div>

For example:

Centered paragraph

icon

πŸ“‚ Collapsible Sections

<details>
  <summary>Click to expand</summary>

  You can include **Markdown**, lists, code blocks, and images inside.

  ```bash
  echo "Hello"

image </details>


For example:  
<details><summary>Click to expand</summary>

You can include **Markdown**, lists, code blocks, and images inside.

```bash
echo "Hello"

image </details>

Tips:


🈢 Ruby Annotations

<ruby>ζΌ’<rt>hΓ n</rt></ruby>
<ruby>ζΌ’<rp>(</rp><rt>hΓ n</rt><rp>)</rp></ruby>

For example:
ζΌ’hΓ n
ζΌ’(hΓ n)


❌ What’s NOT Allowed


βœ… Quick Reference Table

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

⚠️ Gotchas & Best Practices


🀝 How to Contribute

See CONTRIBUTING.md for guidelines.
By contributing, you agree your contributions are licensed under CC BY 4.0.


πŸ”— References


πŸ“„ License

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