Dynamic Inline HTML Importing with i-html Web Component
<i-html> web component allows you to dynamically import HTML content inline, similar to an <iframe>, but with the content adopted directly into the page. If you’ve used techniques like Hotwire Turbo or GitHub’s include-fragment-element, <i-html> will feel familiar. Here’s a quick demonstration:
<i-html src="/path/to/hello.html">Loading...</i-html>
When JavaScript is enabled, the Custom Element will display “Hello world!”. The <i-html> acts as an empty container that fetches and replaces its contents with the parsed HTML from the specified source.
Under the hood, the <i-html> fetches HTML content from a specified source and injects it into the page. It remains in the DOM, allowing for repeated fetches and dynamic content updates. This makes it more versatile than elements like <include-fragment>, which replace themselves upon loading.
text/event-stream mode.<a> tags to target and update an <i-html> element, creating dynamic navigation without page refreshes.<form> in <i-html> for a seamless form submission experience, or use formaction attributes on buttons for different actions.insert attribute to append or prepend new items to a list fetched by <i-html> element.1. Install & download.
# NPM $ npm install i-html-element
2. Import the i-html-element web component.
<script src="/path/tp/i-html.min.js" defer></script> // OR <script type="module" src="node_modules/i-html-element/i-html.js"></script>
1. Place an <i-html> tag on your page and set the src attribute to the URL of the HTML content you want to import.
2. See the demo page for more details like Targeting with Links, Targeting with Forms, Targeting the Response, Streaming Mode, Insertion Mode, Deferring Loading, and more.
03/15/2026
The post Dynamic Inline HTML Importing with i-html Web Component appeared first on CSS Script.
In honor of its Animal Crossing series' 25th anniversary, Nintendo has a special treat for…
In honor of its Animal Crossing series' 25th anniversary, Nintendo has a special treat for…
In honor of its Animal Crossing series' 25th anniversary, Nintendo has a special treat for…
A representative for pop star Katy Perry has issued a strongly worded response to sexual…
A representative for pop star Katy Perry has issued a strongly worded response to sexual…
ABILENE, Texas (KTAB/KRBC) – Dr. Paul Fabrizio was honored Monday at McMurry University by State…
This website uses cookies.