SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast
    Join Date
    Oct 2006
    Posts
    65
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to include header in html

    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

  2. #2
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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):
    HTML Code:
    <!--#include virtual="/header.shtml"-->
    Of course, your web server must be set up to process SSI.
    Birnam wood is come to Dunsinane

  3. #3
    SitePoint Enthusiast
    Join Date
    Oct 2006
    Posts
    65
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by AutisticCuckoo View Post
    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):
    HTML Code:
    <!--#include virtual="/header.shtml"-->
    Of course, your web server must be set up to process SSI.
    Thanks a lot.but can you please tell me more about that..
    i just want to develop very basic html website..
    Thanks in advance

  4. #4
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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:
    HTML Code:
    <!--#include virtual="/header.shtml"-->
    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 file="../inc/header.shtml"-->
    Birnam wood is come to Dunsinane

  5. #5
    SitePoint Enthusiast
    Join Date
    Oct 2006
    Posts
    65
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks a lot Mr.AutisticCuckoo.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •