Skip to content

VSADX/html-imports

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 

Repository files navigation

Include HTML from other HTML files

🌌 What is an HTML import?
It's a <link rel="text/html" href="some_url"> element.

🌄 What does it do
Your <link> will get replaced by the HTML (CSS too) at the url inside href=""

🌆 How does it work?
The JavaScript library will grab all <link> element that include rel="text/html". Then it downloads the content from the page at the link. Finally, it replaces your <link> using the HTML or CSS downloaded.


Live CDN link

<script src="https://cdn.jsdelivr.net/gh/VSADX/html-imports@main/html-imports.js" type="module"></script>  

Examples

The basics

  1. Here's how you use HTML imports, there are just two files here (header.html, about-us.html).
  2. header.html is going to get imported into about-us.html
  3. Your main page needs a normal <body> element, but don't put one in your mini-pages.

header.html

<header>
  <h1> Wow brand! </h1>
</header>

about-us.html

<body>
  <link rel="text/html" href="./header.html">
  <div>
    Welcome to our page, see our brand above! <br>
    We are so professional
  </div>
</body>

About

Really simple options for including HTML or CSS in other files. No web server required.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published