Hi all..i'm so wondering how to include header in html.I have many pages..so i just want to include header like in php just use <? include ("header.php") ;?>
How do i do in html.
Thanks in advance
| SitePoint Sponsor |
Hi all..i'm so wondering how to include header in html.I have many pages..so i just want to include header like in php just use <? include ("header.php") ;?>
How do i do in html.
Thanks in advance


There is no 'include' feature in HTML, unfortunately.
You have to use a server-side scripting language like PHP, or user server-side includes (SSI):
Of course, your web server must be set up to process SSI.HTML Code:<!--#include virtual="/header.shtml"-->
Birnam wood is come to Dunsinane


SSI (server-side includes) allow you to include files into other files. As you see from my example, they look like HTML comments.
The server must be set up to process SSI. You need to talk to your hosting company about that. Often, a web server will only process for SSI if the file type is .shtml (server HTML). It is possible to make the server do this for regular .html files as well, but on shared hosts this may not be an option because the hosting company doesn't want the extra overhead for static files.
So, if you put the HTML markup for your header in a file called header.shtml in your root directory, and you name your start page index.shtml, you can include the header where you want it by using the syntax I showed earlier:
There are two flavours available. The method I've shown here, using virtual= specifies the path from the site root. Another option is to use relative paths with file=:HTML Code:<!--#include virtual="/header.shtml"-->
HTML Code:<!--#include file="../inc/header.shtml"-->
Birnam wood is come to Dunsinane
Thanks a lot Mr.AutisticCuckoo.
Bookmarks