Embed HTML

by mnaoumov
5
4
3
2
1
Score: 38/100

Description

Category: Note Enhancements

The Embed HTML plugin lets you place local HTML documents inside notes with more control than a simple file embed. It supports width and height shorthands, content fitting layouts, CSS based sizing rules, borders, rounded corners, background styling and commands to open the source page in a new tab or external browser. The embedded view can follow stylesheet imports, scripts, images and fonts, and it can react to content size changes as the page loads. The README also covers color scheme handling, scrolling to an element by id and extracting a specific element, which makes the plugin useful for demos, widgets and self contained web pages stored in your vault.

Reviews

No reviews yet.

Stats

stars
14,895
downloads
0
forks
61
days
NaN
days
NaN
days
0
total PRs
0
open PRs
0
closed PRs
0
merged PRs
0
total issues
0
open issues
0
closed issues
0
commits

Latest Version

Invalid date

Changelog

README file from

Github

Embed HTML

Buy Me a Coffee GitHub release GitHub downloads Coverage: 100%

This is a plugin for Obsidian that adds support for embedding HTML files.

Screenshot

Usage

A demo vault with usage examples ships with every release. You can access it via any of the following:

  1. Running the Embed HTML: Open demo vault command.
  2. Downloading embed-html-demo-vault-<version>.zip (<version> is the release version) from the Releases.
  3. Browsing its source in demo-vault/ in this repository.

Supported extensions

You can embed HTML pages from files with following extension:

  • htm
  • html
  • shtml
  • xht
  • xhtml

Embed HTML with default width, height from plugin settings

![[file.html]]

Embed HTML with custom width

![[file.html|400]]

Embed HTML with custom width and height

![[file.html|400x300]]

Embed HTML with custom height only

![[file.html|x300]]

Auto-fit the embed to its content

Use the - marker (shorthand for the CSS fit-content keyword) to size a dimension to the embedded content instead of a fixed value — no inner scrollbar when the content overflows, and no empty gap when it is shorter:

![[file.html|-]]        # default width, height fits the content
![[file.html|600x-]]    # width 600px, height fits the content
![[file.html|-x400]]    # width fits the content, height 400px
![[file.html|-x-]]      # both fit the content

The embed updates reactively as the content's size changes (e.g. images finishing loading, expandable sections).

Full sizing control (CSS declarations)

For finer control — including min/max clamps — pass a list of CSS declarations. Any of width, height, min-width, max-width, min-height, max-height are accepted, with any CSS length/percentage or a content keyword (max-content, min-content, fit-content):

![[file.html|height: max-content; min-height: 200px; max-height: 800px]]
![[file.html|width: 50%; min-width: 300px]]

Unknown properties and invalid values are ignored, falling back to the defaults from the plugin settings.

Default sizing settings

The plugin settings provide global defaults for all six properties (Default width, Default height, Default min/max width, Default min/max height), grouped by axis. Default width and Default height also accept a content keyword to make auto-fit the default. Any per-embed token overrides these defaults.

Border and background

The plugin settings provide global appearance defaults applied to every embed box, under Settings → Embed HTML → Appearance:

  • Border — any CSS border shorthand (e.g. 1px solid var(--background-modifier-border)). Empty for none.
  • Border radius — any CSS border-radius value (e.g. 8px); a bare number is treated as pixels. When set, the embed's corners are rounded and its content is clipped to the rounded box. Empty for square corners.
  • Background — any CSS background value (e.g. var(--background-primary)), painted behind the HTML content. Empty for none.

Open in new tab

Enable Settings → Embed HTML → Behavior → Open in new tab to make opening an HTML file put it in a new tab instead of replacing the content of the current one, without holding a modifier key. When enabled, the first HTML file still reuses an empty tab (so you do not get a blank leftover tab); each subsequent HTML file opens in its own tab. The setting is off by default, preserving Obsidian's standard behavior.

Open in external browser

Every embed carries an Open in external browser button, which hands the file to your system's default browser — useful for a document you would rather read with the tabs, zoom, find and print a real browser brings. The embed itself still renders in the note; the button is an addition, not a replacement.

Turn it off under Settings → Embed HTML → Behavior → Show "Open in external browser" button (Desktop only). The setting is on by default.

[!WARNING]

Scroll-to-element and extract-element do not apply in the browser. The button hands over the file and nothing else, so the embed's #id subpath is left behind:

![[MyDocument.html#section-3]]
![[MyDocument.html#section-3&mode=extract]]

Both still scroll and extract in the note, but the browser opens the whole document from the top. Those two modes are work the plugin does on the embedded document itself — a browser only ever receives the plain file.

It is desktop only: Obsidian exposes no way to hand a local file to a browser on mobile, so the button is never rendered there and the setting is inert rather than broken.

Stylesheets, scripts, images and fonts

An embedded document keeps working with the files next to it. Relative paths resolve against the HTML file's own location, so a document that opens correctly in a browser renders the same way in a note:

<html>
  <head>
    <link rel="stylesheet" href="styles/main.css" />
    <script src="scripts/app.js"></script>
  </head>
  <body>
    <img src="https://raw.githubusercontent.com/mnaoumov/obsidian-embed-html/HEAD/images/diagram.svg" />
  </body>
</html>

Stylesheets get special treatment. Obsidian's Content-Security-Policy reaches into the embed and blocks every external stylesheet — a <link rel="stylesheet"> is fetched and then silently ignored, leaving the document unstyled. The plugin therefore reads each stylesheet and inlines it as a <style> element, which the policy does allow. This covers:

  • stylesheets in the vault, wherever they sit relative to the HTML file;
  • stylesheets on the web (https://…), read through Obsidian's own request API so they are not blocked by CORS;
  • @imported stylesheets, followed recursively;
  • stylesheets a script in the document adds while it runs.

Relative url() targets inside a stylesheet — background images, @font-face sources — keep resolving against that stylesheet's location, not the note's or the HTML file's, so fonts and images referenced from CSS in a subfolder still load. Scripts, images, fonts and media are not restricted by the policy and load on their own.

Color scheme

The embedded HTML follows Obsidian's base color scheme (Settings → Appearance → Base color scheme), independent of your operating system's theme. The active scheme is propagated into the embed, so prefers-color-scheme media queries in your HTML resolve to Obsidian's Dark/Light setting (and to the OS when set to Adapt to system). Switching the base color scheme updates already-rendered embeds live.

Embed HTML and scroll to the element with id

![[file.html#foo]]

or

![[file.html#foo&mode=scroll]]

Embed HTML and extract element with id

![[file.html#foo&mode=extract]]

Installation

The plugin is available in the official Community Plugins repository.

Beta versions

To install the latest beta release of this plugin (regardless if it is available in the official Community Plugins repository or not), follow these steps:

  1. Ensure you have the BRAT plugin installed and enabled.
  2. Click Install via BRAT.
  3. An Obsidian pop-up window should appear. In the window, click the Add plugin button once and wait a few seconds for the plugin to install.

Debugging

By default, debug messages for this plugin are hidden.

To show them, run the following command in the DevTools Console:

window.DEBUG.enable('embed-html');

For more details, refer to the documentation.

Support

My other Obsidian resources

See my other Obsidian resources.

License

© Michael Naumov

Similar Plugins

info
• Similar plugins are suggested based on the common tags between the plugins.
Snippetor
5 years ago by ebullient
An assist for creating CSS snippets for Obsidian
Topic Linking
5 years ago by Liam Magee
An Obsidian plugin for finding and linking topics in a vault.
Copy as HTML
5 years ago by Bailey Jennings
A simple plugin that copies the selected text to your clipboard as HTML
Link Embed
4 years ago by SErAphLi
This plugin allow you to convert URLs in your notes into embeded previews.
Notion Video Embed
4 years ago by lastknightcoder
Obsidian Enhancing Export
4 years ago by YISH
This is an enhancing export plugin base on Pandoc for Obsidian (https://obsidian.md/ ). It's allow you to export to formats like Markdown、Markdown (Hugo https://gohugo.io/ )、Html、docx、Latex etc.
Local Quotes
4 years ago by ka1tzyu
📜 Collect your quotes from all over the vault and embed them in different locations with refresh delays
Group Snippets
4 years ago by Mara-Li
Create folder of snippets to activate them in one click !
Embed Code File
4 years ago by Abdullah Almariah
Script Launcher
4 years ago by Alessandro Ruggiero
An Obsidian plugin that allows you to easily run scripts written in any language directly from the app
Copy document as HTML
4 years ago by mvdkwast
Obsidian plugin: copy document as HTML, including images
Obsidian markdown export
4 years ago by bingryan
This plugin allows to export directory/single markdown to a folder. support output format(html/markdown/text)
Paste As Html
4 years ago by maotong06
Webpage HTML Export
4 years ago by Nathan George
Export html from single files, canvas pages, or whole vaults. Direct access to the exported HTML files allows you to publish your digital garden anywhere. Focuses on flexibility, features, and style parity.
Canvas CSS class
4 years ago by Lisandra-dev
A plugin that will add a css class to your canvas & adding to each canvas the path to help personnalization
Hyphenation
4 years ago by 7596ff
Enables justified text and hyphenation
Custom Classes
3 years ago by Lila Rest
A minimal Obsidian plugin that allows you to add your own HTML classes to chosen Markdown elements directly from your notes.
Html Server
3 years ago by Pr0dt0s
Obsidian plugin to serve a vault as an html site.
Importer
3 years ago by Obsidian
Convert your data to Markdown files you can use in Obsidian. Works with Apple Notes, OneNote, Evernote, Notion, Google Keep, and many other formats.
Style Text
3 years ago by Juanjo Arranz
Apply custom CSS styles to selected text in your Obsidian Notes
RunJS
3 years ago by eoureo
Let's run JavaScript easily and simply in Obsidian.
GitHub Embeds
3 years ago by Gino Valente
Embed GitHub issues, PRs, and code snippets directly in Obsidian
Copy as source
2 years ago by @gapmiss
Select and copy source HTML in reading view in Obsidian.md
Smart HTML Select
2 years ago by Isaia Riva
An Obsidian plugin to insert a smart HTML select element into the editor
Regex Mark
2 years ago by Mara-Li
ii
2 years ago by Wilson
The main feature of this plugin is to quickly insert common Markdown code and HTML code, including Sup, Sub, Audio, Video, Iframe, Left-Center-Right Alignment, Variables, Footnotes, Callout, Anchor Points, HTML Comments and so on.
Paste as Embed
2 years ago by Matt Laporte
Obsidian plugin to paste contents of clipboard into a new note, and embed it in the active note.
CSS Inlay Colors
2 years ago by Benji Grant
Show inline color hints for CSS colors in Obsidian
CSS Inserter
2 years ago by Erika Gozar
Inserts user-defined css snippets into the selected text.
Style Settings
5 years ago by mgmeyers
A dynamic user interface for adjusting theme, plugin, and snippet CSS variables within Obsidian
Better File Link
5 years ago by Marc Julian Schwarz
A plugin for the note taking app Obsidian to add better external file links to your notes.
Snippet Commands
5 years ago by death_au
Registers custom css snippets as commands (which you can bind hotkeys to)
MySnippets
5 years ago by Chetachi
MySnippets is a plugin that adds a status bar menu allowing the user to quickly manage their snippets within the comfort of their workspace 🖌.
Auto Class
5 years ago by Nathonius
Automatically add CSS classes to notes based on file path.
Remove HTML Tag
2 years ago by ChenPengyuan
Figma Embed
2 years ago by Kyle Kochanek
Obsidian plugin to embed live Figma files in your markdown notes.
Local Media Embedder
2 years ago by seyf1elislam
an obsidian plugin allows you to Embed videos and images and audios from your local device in your notes.
Arweave Uploader
2 years ago by makesimple
Insta TOC
2 years ago by Nick C.
Generate, update, and maintain a table of contents for your notes while typing in real time.
Image to HTML
a year ago by 0x1DA9430
A plugin for Obsidian that converts pasted images to HTML format instead of Obsidian's wikilink or Markdown format
Model Viewer
a year ago by Janis Pritzkau
An Obsidian plugin to view and embed 3D models using Google’s <model-viewer> component.
Send to Canvas
a year ago by wenlzhang
An Obsidian plugin that allows you to send tasks, blocks, and notes to Canvas files as plain text, links, and embeds.
Auto Close Tags
a year ago by k0src
Obsidian MD plugin to auto-close HTML tags.
Custom Theme Studio
10 months ago by @gapmiss
An Obsidian.md plugin to create and tweak custom themes with live CSS editing, element styling, and instant previews. All without leaving Obsidian.
Path in tab title
3 months ago by d9k
This plugin has not been manually reviewed by Obsidian staff. Show folders names in the tabs titles.
Convert url to preview (iframe)
2 months ago by fhachez
Convert a URL (e.g. YouTube) into an iframe (preview).
Note Toolbar
a month ago by chrisgurney
Add customizable toolbars to your notes.