4

I am having a header which it will be uniform in all the pages. I want to make it generic. So I want to include common header in every HTML Page.

When i checked for HTML includes i cameup with SSI which needs a server. My Requirement is I want to include HTML file in another WITHOUT a server.

Rajasekar
  • 18,392
  • 34
  • 106
  • 137
  • 2
    Please explain the use case. Unless you're serving the files locally (using `file//`) you'll need a server. – steveax Apr 24 '12 at 07:52
  • people want to do quick dev testing without a server and it is very convenient to be able to do html includes without a server. – Joshua Robison Jul 16 '22 at 07:22

4 Answers4

1

The way I would do it would be to make a "hanger" div with a class of .header. Then put a <p> inside the div to put alt text into. Then in your main css stylesheet apply your header image as a background image, and negatively indent the text.

Example
.hanger {background-image:url(header.png); text-indent:-1000px;}

To resize the header all you would do is put a width and height on div.hanger.

Does this help?

SamStar
  • 335
  • 2
  • 17
0

I've never heard of including html in another html file. I think what you can trying to do can be accomplished using an iframe.

example: header.html

apak
  • 55
  • 3
  • 11
0

This later question got an answer that works with files on disk provided you are using firefox.

Chrome gives a cross site scripting error

Community
  • 1
  • 1
David Sykes
  • 48,469
  • 17
  • 71
  • 80
-1

You could have a <div> for the header, I will call it <div id="header">. Using jQuery we could say something like: $('#header').load(---html file---);. Aside from the pain it might be to include the JS file in all pages, it will allow you to make changes to the header globally throughout your application.

Wizard
  • 69
  • 1
  • 3