Including header files in HTML pages

RTKHOT
RTKHOT used Ask the Experts™
on
Including header and footer files in ASP was very easy.

But how do I achieve it in a pure HTML page?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Dave BaldwinFixer of Problems
Most Valuable Expert 2014

Commented:
You can't.  'pure' HTML does not have a command to do that.  Something other than HTML is always required to do that.
Developer & EE Moderator
Fellow 2018
Most Valuable Expert 2013
Commented:
Dave, can you turn on serverside includes?

Otherwise, you could do this in js or jquery. I prefer using jquery..
<script>
$(function() {
$.ajax({
  url: "myHeader.html",
  cache: false
})
  .done(function( html ) {
    $( "#header" ).append( html );
  });
 });
</script>
<div id="header"></div>

Open in new window

Dave BaldwinFixer of Problems
Most Valuable Expert 2014

Commented:
Dave, can you turn on serverside includes?
Yes but that is still not 'pure' HTML.
HTML inside "includes" need some server side technology way to insert. You can also think of IFRAME way.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial