Mywebdunia's Blog

How do I include one HTML file inside another?

Posted by: Amit Nazare on: March 17, 2009


It is a common practice by web developers to make separate header and footer files. As there wont be any changes in these section in any of the pages.

So now the question arises how to use these HTML pages inside another HTML file. There is a solution for this that is

<!–#include VIRTUAL=”/common/header.htm” –>

So the above code makes the header file to include in another HTML file. Just paste this code change the path and use it where you want your header to be displayed.

5 Responses to "How do I include one HTML file inside another?"

TFS, but will this work for extremely plain and static HTML?

I see tags like : server side includes, SSI

Could you Throw some more light here please?

Ya it will work. SSI, or Server Side Includes, were first developed to allow Web developers to “include” HTML documents inside other pages. And you need to activate SSI for this. SSI is handled by the webserver.

Oh. Isn’t there any other way to do this, with just basic plain HTML hostings?

The other method could be using JavaScript, say for example if you have your footer is in separate file say for example you need to have footer.js written as:

document.write(“<div id=’footer’>Copyright © 2009. All rights reserved</div>”);

then later use the below code in your html file
<script language=”javascript” src=”footer.js”>

Hey that’s handy. Thanks

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.