"Is there a way to do something like that in HTML document?"
Yes there is an HTML equivalent (if I can say) to include files, and it's called Server-side Includes (SSI) which uses the .shtml
file extension, however this is an Apache feature. Yet, from a recent finding, it can run on Windows servers. Consult Microsoft's Developer Network for more information on the usage of SSI and this page also on Microsoft's IIS.net.
The syntax is: (no space between the <!--
and the #include...
)
<!--#include virtual="/includes/file.shtml" -->
This would look and fetch a file called file.shtml
to the root and inside the "includes" folder.
Note: This can be any folder you want it to be.
You can also include different file extensions such as .htm
.html
.txt
and even another .shtml
file.
I manage a few Websites with that particular file extension, and the benefit of including .shtml
files, is that you can also do more includes inside those, but not with the other file extensions I already listed.
However, there is an exception to this rule. You can tell the server to treat .html
or .htm
to run as .shtml
just as long as you use the
AddHandler server-parsed .html
AddHandler server-parsed .shtml
AddHandler server-parsed .htm
Apache commands inside an .htaccess
file and placed in the root of your server.
Back to the matter at hand. You can use it anywhere in the document you wish to include a file in.
For more information on Server-side Includes and other available options, visit the Wikipedia Website, or Google the term "Server-side Includes (SSI)".