How do I include 1 html file in another html file?

United States
July 10, 2007 11:58pm CST
I want to create a menu.html file and insert it into all the pages that I create for my website. This way, when I need to edit the menu, I just need to edit the menu.html file. I have looked at some include commands on the internet and for some reason they are not work. If you know anything about html, php, or asp that would be useful for creating menus let me know. Thanks.
1 person likes this
5 responses
@aanova (6)
• Philippines
11 Jul 07
if that's plain html that's impossible like what the other said there should a server side include and you should change you.html to something like .php .asp etc.
@migenKC (792)
• Philippines
12 Jul 07
i agree to you darknessfallz... you can always use framing...
• Ireland
11 Jul 07
You need some php so you can do
@good1030 (670)
• China
11 Jul 07
Hi Nblax, I am so sorry that I am not an expert in HTML code and web development, but I just try to search the answer for you, hopefully this will work for you. The easiest way, by far, is to use "server side includes" in your HTML. Almost all web servers support this, except for free web hosting companies. This is overwhelmingly the preferred way to go. SSI, or Server Side Includes, were first developed to allow Web developers to "include" HTML documents inside other pages. If your Web server supports SSI, it's easy to create templates for your Web site. First save the HTML for the common elements of your site as separate files. For example, your navigation section might be saved as navigation.html or navigation.ssi. And then use the following SSI tag to include that HTML in each page. (!--#include virtual="path to file/include-file.html" --) Finally, use that same code on every page that you want to include the file. IF IT DOESN'T SEEM TO WORK, TRY NAMING YOUR FILE WITH A .shtml EXTENSION, instead of .html. Or you can use client side method to include one HTML file in another, for example, Javascript method. JavaScript is another way to include HTML within the pages of your site. This has the advantage of not requiring server-level programming. But it's a little more complicated than the server-level include methods. First of all, save the HTML for the common elements of your site to a JavaScript file. Any HTML written in this file, must be printed to the screen with the document.write function. And then use a script tag to include the JavaScript file on your pages. (script type="text/javascript" src="path to file/include-file.js") (/script) Finally use that same code on every page that you want to include the file. If this answer doesn't work properly for you, I recommend you to go to this site, http://www.boutell.com/newfaq/creating/include.html to look for the answer, and you can ask the author questions if his answer still not working.
@good1030 (670)
• China
11 Jul 07
Make sure you change the () to in the code.
• United States
11 Jul 07
Thanks. I am useing free hosting but I will give it a try.
• Pakistan
15 Jul 07
you check these sites for help,,, http://www.ehow.com/how_12995_create-frames-based.html or http://www.uwec.edu/help/FpageXP/frm-start.htm you can insert one page to other only with Frames,, i think you can find some good information about the thing you want to know.. Best of Luck
• India
16 Jul 07
hello , i will guide you step by step, Enter 1 file in another called Server Side Includes. Your will have to learn Server Side Includes [SSI]. You can do this in html file also but your file name should be like .shtml or .shtm not html or htm. Also you can use any programming languages because all programming laguages like asp,asp.net,php etc have code to insert file in another , specially top, menubar ,bottom etc. see site http://www.infotechwebsolutions.com is the good example of Server side includes. Feel free to contact me.
@stmartin (157)
• Macedonia
18 Jul 07
I think the best solution here is the frame set. Just look this link, it'll help you. http://w3schools.com/html/html_frames.asp Check the examples.