views:

144

answers:

6

I was wondering wether there is a way to include some html content inside another html using only html?

A replacement to PHP's

<?php include("file.php"); ?>

Is this possible?

EDIT:

This has brought up some confusion, what I needed was "almost an html tag" that had the functionality of including a html document in another.

+2  A: 

There's no such thing. You'd have to use a server-side scripting language or JavaScript to do something like this.

Tyler
A: 

Yes there is but you need to enable it in your config or .htaccess:

Options +Includes
AddType text/html .shtml
AddHandler server-parsed .shtml

Of course with that youd need to rename any file doing the including to .shtml... or you could jsut use:

Options +Includes
AddType text/html .html
AddHandler server-parsed .html

the syntax itself is similar to comment:

<!--#include virtual="/footer.html" -->
prodigitalson
it is not html.
Col. Shrapnel
well no, but it doesnt require something like PHP either.
prodigitalson
This is a server-side include, not plain HTML. Just as easy, if not easier, to use JavaScript probably.
Tyler
@tyler: except for then youre moving client side and generating a bunch of extra requests...
prodigitalson
but it does require something else! why not to use PHP then?
Col. Shrapnel
@Tyler javascript is not a solution. Don't be silly, use PHP
Col. Shrapnel
I agree with Col. Shrapnel
Trufa
@Col Shrapel: Well i would jsut use php as well, but the point is this is essentially built in to Apache and IIS so it doesnt require a 3rd party module being installed. That would be the only reason. But really, who DOESNT have PHP isntalled? It makes no sense to me either... but i didnt ask the question :-)
prodigitalson
@Col. Shrapnel: I was going under the assumption OP was trying to avoid a server-side solution for whatever reason. If I were in his position of course I'd use PHP.
Tyler
+1  A: 

the only thing would be an iframe which is pure html. but you also can use javascript to get the page via ajax and include it into your dom hirarchy

ITroubs
No, I cant use iframes. thanks
Trufa
+5  A: 

It cannot be done purely by HTML. (There are iframes, however, but I don't think that qualifies in this case.)

It can be done using JavaScript. You get the other file via Ajax, and place its contents inside an HTML element on the current page.

Šime Vidas
I am very limited, I am actually asking for fmbl tab pages in facebook.
Trufa
+1  A: 

If you're using Apache, you can try Server Side Includes.

Alex Howansky
+2  A: 

HTML does not have a feature to include additional content natively. However most web servers do have server-side include statements:
SSI in Apache
SSI in IIS

Matt H.