Hyper Text Markup Language (HTML) Question:
Download Questions PDF

I am trying to include a HTML document in another document...Is there a way to do this?

Answer:

Yes, there are several ways to do this. But remember, HTML is not a programming language - it doesn't have `directives': it's a markup language, so trying to compare it to C or Pascal is not going to be very meaningful.

SGML already provides the standard way to do this, using an entry in the DocType Declaration for a file:

<!doctype html public "-//IETF//DTD HTML 3.0//EN" [
<!entity foo system "bar.html">
]>
...
and then later when you want to include the file
...
&foo;

This is the General Entity mechanism used universally in normal SGML work and does exactly what is wanted, with the added benefit that you can have multiple occurrences of &foo; if you need to include some text at more than one place. Unfortunately none of the browsers except Panorama support it, basically because very few of the programmers who write browsers bothered to read up on what can be done.
* The second way is to use the facilities of your server. This has to be enabled by someone with access to the server configuration files (ask your WebMeister). For example, the NCSA server lets you embed a command inside an SGML comment:

<!--#exec cmd="cat myfile.html"-->
Provided this occurs in a file with a special file type (eg .shtml, and this is what has to be specified in the server configuration), the server will parse the file and send out the result of the command embedded in the document.
* There is in fact a vastly easier way to do this. SGML provides a PI mechanism (Processing Instruction) in the form:

<?cat myfile>
SGML/HTML couldn't care what you put inside (except it must not, for obvious reasons, contain the `>' character!). This would be a great way to specify a page break, for example: suppose you were processing an SGML file using PostScript, you could say <?showpage>...but again, none of the browsers except Panorama support this, again because they guys who write them have never bothered to actually read up on how SGML works.

Download HTML Interview Questions And Answers PDF

Previous QuestionNext Question
Can I use any HTML in the box?The colors on my page look different when viewed on a Mac and a PC.