I honestly believe that HTML does not have it, but it's not the end of the world. =)
There are two alternatives, but they are not pure HTML:
1. JavaScript / JQuery:
In many ways, you can simply use $.get()
along with .html()
, to enter the content you get.
The $.get()
will get the HTML of the URL you entered, then just insert the obtained HTML into some element you want, for example $('menu').html(meu_html)
.
In a basic example would be:
<menu></menu>
<script>
$.get('seu_menu.html',
function(data) {
$('menu').html(data);
}
);
</script>
Want an example? So ...
$.get('https://developer.mozilla.org/en-US/docs/Web/',
function(data) {
topbar = data.split('<header id="main-header">');
topbar = topbar['1'].split('</header>');
$('menu').html('<header id="main-header">'+topbar['0']+'</header>');
}
);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><linkhref="https://developer.cdn.mozilla.net/static/build/styles/mdn.90e6d84d58ff.css" rel="stylesheet" type="text/css">
<link href="https://developer.cdn.mozilla.net/static/build/styles/wiki.978c53db5cdd.css" rel="stylesheet" type="text/css">
<menu></menu>
<main id="content">
Resto do meu site
</main>
2. Server-Side:
You can include content easily via PHP, for example, using include
.
<?php
include('meu_menu.html');
?>
The include
in this case will insert the contents of another file. This way you can have a document (usually: navigation menu, top, footer) being part of all pages. Once this document is updated, all pages will show the modified file, without wanting to edit one by one.