Skip to content
FeaturesPricingBlogDownload
Home / Markdown syntax / HTML in Markdown

HTML in Markdown

Markdown lets you write raw HTML anywhere in a file: inline tags such as <kbd> inside a sentence, or whole blocks such as a <div>. CommonMark passes the HTML through unchanged, but the app that displays the file decides what to keep. GitHub removes some tags and attributes, and many note apps and converters drop HTML entirely, so use it only for things Markdown has no syntax for.

Press <kbd>Ctrl</kbd>+<kbd>C</kbd> to copy.

H<sub>2</sub>O and x<sup>2</sup>

What is HTML in Markdown used for?

The common reasons are features Markdown does not have:

  • Keyboard keys with <kbd>, subscript with <sub>, superscript with <sup>.
  • A line break inside a table cell with <br>.
  • Collapsible sections with <details>. See collapsible sections.
  • Image size or centering with <img width="300"> or <p align="center">, common in GitHub READMEs. See images.
  • Hidden notes with <!-- -->. See comments.

How do HTML blocks work?

A line that starts with a block-level tag such as <div>, <table> or <details> starts an HTML block, and in CommonMark the block runs until the next blank line. Markdown inside that block is not processed. To use Markdown inside an HTML element, leave a blank line after the opening tag and before the closing tag:

<div align="center">

**This is bold**, because blank lines surround it.

</div>

Without the blank lines, **This is bold** would show the asterisks. This blank line rule is the most common reason HTML and Markdown mix badly.

Inline tags such as <span>, <kbd> and <sub> work inside a paragraph, and Markdown between them, such as <sub>*x*</sub>, is still processed.

What does GitHub remove?

GitHub sanitizes HTML before showing it. Scripts, <style> blocks and style attributes are removed, so inline CSS for colors or fonts does not survive. Attributes such as align, width and height on common elements are kept, which is why READMEs use them for layout.

Where does HTML in Markdown work?

App or spec Raw HTML
CommonMark Passed through unchanged
GitHub Rendered after sanitizing; no scripts or style attributes
VS Code preview Rendered; scripts are blocked by default
Obsidian Most HTML renders in reading view
Noteline Kept in the file; not rendered or exported

When should you avoid HTML?

  • When the file will be read as plain text. Tags make the source harder to read, which removes the main benefit of Markdown.
  • When it will be converted. Pandoc keeps raw HTML only in HTML-like output. In Word and PDF output the tags are dropped.
  • When Markdown can do it. Use **bold** instead of <b>, [text](url) instead of <a href>, and a GFM table instead of <table> unless you need merged cells.

HTML in Noteline

Noteline keeps HTML in the file exactly as typed but does not render it. In live preview, a block of HTML such as a <div> is hidden until you move the cursor onto it with the arrow keys, and inline tags like <kbd> show as typed. The source view, Cmd+Shift+M on a Mac or Ctrl+Shift+M on Windows and Linux, shows everything. HTML export, printing and the desktop app's Word and PDF export leave raw HTML out: HTML blocks are dropped with their content, and inline tags are removed while the text between them stays.

Common questions

Can I put Markdown inside an HTML tag?

Inside inline tags, yes. Inside block tags, only after a blank line, as shown above. Some renderers add their own rules, such as a markdown="1" attribute in PHP Markdown Extra.

Is HTML in Markdown safe?

It depends on the renderer. A file from someone else can contain scripts or links that run code, which is why GitHub and most apps sanitize or remove HTML.

Why does my HTML show as text?

Either the renderer escapes HTML, or the tag is malformed, for example a missing >. A tag name followed by a space, such as < div>, is not HTML in CommonMark.

Noteline

Download Noteline↓See pricing→

Related

  • Collapsible sections in Markdown
  • Comments in Markdown
  • Markdown images
  • Markdown headings
  • Markdown for beginners: the 15-minute guide
  • Markdown syntax

A Markdown note editor with everything you need

We’re listening

Tell us what you need or what gets in your way. If something isn’t working, write to us any time.

contact@noteline.io→

Product

  • Download
  • Pricing
  • Features
  • Changelog

Learn

  • Markdown syntax
  • Use cases
  • Blog

Compare

  • vs Obsidian
  • vs Notion

Support

  • Help
  • Support
  • Privacy
  • Terms

© 2026 Notelinecontact@noteline.io