Embedded HTML block

Sometimes it makes sense to have some block HTML code separated from the main part of the code. For example, the footer with a navigation menu is considered to be placed on each page and to be modified just by editing one reference file.

The solution had been found here, but the final original reference is the w3.org article.

So, what to do:

<!-- ...text before... -->
<OBJECT data="file_to_include.html">
Warning: file_to_include.html could not be included.
</OBJECT>
<!-- ...text after... -->

The content between <OBJECT> and </OBJECT> tags is displayed if the data is unable to be included.

The block creates a new viewport for desired HTML-document look, which is placed inside, so here is an underwater stone – links processing inside an embedded block: they will open in this embedded viewport (may reach a funny recursion pattern). To prevent behavior alike, the links have to contain target="_parent" or target="_blank" properties.

What’s more: the parent’s CSS is not inherited. Hard to say if it’s a benefit or weak point, but the CSS may be linked to the HTML code to embed additionally if needed.

There is something said of anchor-defined HTML documents, so unexpected closing tags may be suddenly included and lead, e.g., to unexpected end of file in the main document, but I’ve tried several cases – could not reproduce anything wrong, can’t realize yet what do they mean.

What I’ve noticed, embedded HTML renders a little later than main HTML, so it appears with some tenths of seconds delay.

This entry was posted in HTML, web. Bookmark the permalink.