Why Does HTML Still Not Offer This Feature Natively
Potentially the most underrated missing feature in web design
I’ve run into this issue countless times. And I am not even a full-time web developer. I do this for fun. But the absence of this feature is blatantly obvious. Or is it just me? Let’s explore!
HTML5 is awesome
Let me start this post with a quick disclaimer: HTML5 is awesome! So is CSS. I have no complaints about the general state of web technologies and web development. What we’re nowadays able to do with only HTML and CSS is outstanding, compared to even a few years back when much of this was merely possible through Javascript or other technologies.
To the point
In all these years though, I’ve been missing a feature in HTML that to me is a no-brainer addition. But as I questioned in the intro: Is it just me?
Maybe this feature would take away a chunk of what PHP is good for. Because to work around this missing feature I — and possibly many of you — turn to PHP.
Why is this feature “missing”?
Let me paint you a little picture: You’ve just developed a simple one-page design with HTML and CSS only — gorgeous, functional, and ready to go live. But then you decide to add another page. Maybe a privacy policy. We all need those nowadays, right?
Here’s the problem: I’ve created a cool header, a nice little menu, and a footer. And what do I have to do to create another page? Right, copy all those HTML elements over to the privacy.html file. And only change the main content area in between. You see where I’m going with this, don’t you?
Sure, it’s no real hassle. Copying and pasting don’t take much time. This is not the issue, though, is it? What if I change a small detail in the footer? I’d have to remember to change it in both HTML files. Still do-able. But now picture having a handful of pages, or even dozens. Do you really want to copy and paste every small change to all these files manually? I don’t.
HTML Includes
It baffles me that HTML never had — and as it looks like never will have — a simple include dynamic to reference parts of or whole HTML files from another HTML file.
You know, a simple<include src=”./header.html”></include>
for example. This way, we could design our headers, footers, menus, sidebars, and add them to our main content, however many main content files we need.
Quick PHP fix
Includes are not a real issue, of course. PHP offers a simple and quick solution for exactly that problem. You just rename your files to .php and and add an include function to your index file that references header, footer, menu, etc.
<body>
<?php include "./header.php" ?>
<?php include "./menu.php" ?>
Main content
<?php include "./footer.php" ?>
</body>
PHP handles this include at the server-side level and that’s quick enough for me. Other architectures have similar workarounds to go about this issue: For example Grunt or Gulp.
What it boils down to
We can solve anything in modern web development. The sky’s the limit. A quick PHP fix is all we need to work around this missing feature.
Still, there is something about native HTML, the purity and beauty of plain HTML, that has me wishing for an include feature with basic web markup language. Is that just me?