Skip to content
All referenceBlock Elements

Markdown HTML Block

How to embed raw HTML in markdown for elements not natively supported. Syntax, security considerations, and platform support.

What is markdown html block?

Most markdown parsers allow you to embed raw HTML directly in your markdown file. HTML blocks let you use elements not supported by markdown — custom divs, details/summary, colored text, form elements, and more. HTML support depends on the platform — some sanitize or strip it entirely.

Syntax

Inline HTML

Inline HTML elements can be mixed with markdown text.

Result
Text with red word.

Block HTML

Block-level HTML must be preceded and followed by a blank line.

Result
Custom styled block

Details/summary

Native HTML collapsible section — commonly used in GitHub READMEs.

Result
Click to expandHidden content here.

Platform support

PlatformSupportedNotes
GitHubYesSanitized — style attributes and scripts removed
GitLabYesSanitized HTML
ObsidianYes
DiscordNoHTML rendered as plain text
SlackNo
NotionNoDoes not render raw HTML

Common mistakes

Wrong
<div>content</div> (no blank lines)
Right

<div>content</div>

Block-level HTML elements need blank lines before and after them to be parsed as HTML blocks rather than inline HTML.

Tips for html block

1Markdown inside HTML blocks

By default, markdown is not parsed inside HTML block elements. Use the markdown="1" attribute in some parsers (Kramdown) to enable it.

2GitHub sanitizes inline styles

GitHub strips style= attributes for security. Use class attributes with your own CSS, or rely on native GitHub rendering.

Frequently asked questions

Everything you need to know.

1

Can I use inline CSS in markdown?

On platforms that allow HTML, yes: <span style="color:red">text</span>. However, GitHub strips style attributes for security. Check your platform's HTML sanitization policy.

Related elements

Try it in the editor

Paste your markdown and see html block rendered instantly with professional themes.