Seeking an Answer: Why canât HTML alone do includes?
Seeking an Answer: Why canât HTML alone do includes? êŽë š
Iâm obsessed with this basic web need.
Youâve got three pages:
index.html
about.html
contact.html
You need to put the same header on all three pages.
Our developer brains scream at us to ensure that weâre not copying the exact code three times, weâre creating the header once then âincludingâ it on the three (or a thousand) other pages.

There are so many solutions to this problem
We donât need to list them all here. I documented some of them one time, but there are many more.
Weâve got JavaScript to go fetch
the HTML and insert
it. Weâve got old school web server directives. Any static site generator can do it. Task runners (gulp-include
) can do it. Templating languages tend to have include functionality. Any backend language can generate HTML on the fly. Iâve seen several Web Components purpose-built for this. Weâve got <iframe>
, which technically is a pure HTML solution, but they are bad for overall performance, accessibility, and generally extremely awkward here, but we can extract them. We can just not worry about includes at all and trust our code editors powerful find and replace tools.
But none of the solutions is HTML
None of these are a straightforward HTML tag. None of these are just some HTML way of saying âgo get this HTML and put it hereâ, like <img>
is for âgo get this image and put it here.
Why?
No, really, why?
Iâm sure there are reasons. Normally, web standards and browsers are all about âpaving the cowpathsâ, that is, providing solutions around what developers are already doing. Iâd wager (counts fingers) pretty much all websites need this ability, and all of them reach for different additional non-web-standard tooling to get it done. Thatâs weird.
So what are those reasons?
- Does it wreck the preload scanner? As in, it could have very bad web performance issues?
- Would it have to be async and thus have issues with jerky/shifty loading experiences?
- Does it introduce some kind of complexity that harms the purity of HTML or something?
- Is it the difficulty of handling nested includes? Circular includes?
- Is it pushback from web hosting that a feature like this would increase web requests dramatically?
- Would the restrictions be too strict to make it useful? Like for whatever reason itâs cool to load images and CSS and JS from other domains, but HTML would likely be restricted.
- Is there something problematic about the idea that I havenât listed here?
- Is there actually no real desire for this and Iâm just a weirdo thinking there is?
If anyone has been a part of these discussions or knows exactly why this is, or you just have general thoughts, leave a comment!