Using pure HTML?
Yes, but... it almost certainly does not work the way you expect or need it to work. And you should not do this, given there are various much better alternatives.
What Not to Do
The <object>
tag (see here) can be used - or, rather, mis-used. The problem is it will add your fragment as an embedded document, which means it will have a different context for layout, styling, scripting, and so on.
An example: I have a fragment of HTML in a file fragment.html
:
<div class="stylish">hello world<div>
I have another file welcome.html
containing a full HTML page:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>HTML object tag</title>
<style>
.stylish { color: magenta; }
</style>
</head>
<body>
<h2 class="stylish">demo</h2>
<div class="stylish">
<!-- don't do this! -->
<object data="fragment.html"></object>
<div>
</body>
</html>
Specifically, note the <object data="fragment.html"></object>
line.
Try this for yourself, and you will see that the fragment is indeed included. The "demo" heading is styled, but the "hello world" is not, despite my various attempts. This probably defeats your purpose.
This is a mis-use of the tag, anyway, as it is intended for use with multimedia objects.
Also, this tag can only be used in the body of an HTML page - not in the header (in case that was one of your requirements).
Older HTML tags such as <embed>
and <iframe>
have similar features.
So, Instead...
That brings you back to options discussed in other questions, such as this and this.