I'm creating a web site for an institute, since I'm new to this field I want to know whether I can create a page for header part(which containing the logo and the name of the institute) and can I combine that page to each and every page I'm creating. If it is possible suggest me how can I combine the header part & newly created page..
-
Yes! you can use `iframes` or if you using `PHP` then use `require` and `include` – Rafee Oct 06 '12 at 05:36
-
You can also jquery load function for load external page. – Hkachhia Oct 06 '12 at 05:42
-
possible duplicate of [Why does HTML5 not include a way of loading local HTML into the document?](http://stackoverflow.com/questions/6875404/why-does-html5-not-include-a-way-of-loading-local-html-into-the-document) – Basil Bourque Aug 22 '14 at 14:27
2 Answers
Surprisingly, there is no way to do that in straight HTML. Not even in HTML5.
If you are only creating a few pages, I suggest simply copy-pasting the content to each page's HTML file. Admittedly, that approach can quickly become a burden.
Some web servers will parse the HTML of a page before it is served out, look for a specific kind of HTML comment, and then interpret that as a command to insert the contents of another file. This feature is called "server-side includes" or "SSI". Some web servers, such as Apache Tomcat, have this feature but turn it off by default due to security concerns.
If you are building dynamic pages where the HTML content being served is created on-the-fly with a programming language rather than read from pre-created disk files, then you can definitely include fragments of HTML using that programming language.
I suggest you do some additional study to build up your web authoring skills. One great source of training is the book "Head First HTML with CSS & XHTML" from O'Reilly Media, Inc.

- 303,325
- 100
- 852
- 1,154
-
There is more on [this answer](http://stackoverflow.com/a/6878494/50049) which is answering not if, but _why_ HTML5 doesn't have more elegant means of seamless inclusion (speaking to the 'why must I use something like PHP just for partials?'). The 'seamless' iframe suggestion might be his best shot (and would be a perfectly good suggestion in your answer), it's like an iframe, but common DOM (no parent/child separation). – Tim Post Oct 06 '12 at 14:31
-
@TimPost As for why no standard inclusion feature, perhaps one big reason is security. SSI has been been a security risk in the past. [Apache Tomcat](http://tomcat.apache.org/), for example, ships with SSI features turned off. Also, please vote to close this question, as you found a valid duplicate. – Basil Bourque Aug 22 '14 at 14:26
You can do pull html code from different places and merge them with php. It's been years since I've done it, so I can't get into the particulars.

- 85
- 8