I honestly believe that with HTML there is no way, but this is not the end of the world. =)
There are two alternatives, but they are not purely HTML:
1. Javascript/Jquery:
Among several ways, you can simply use the $.get()
along with a .html()
, to insert the content obtained.
The $.get()
will get the HTML of the given URL, then just insert the HTML obtained into some element you want, for example $('menu').html(meu_html)
.
In a basic example it 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>
<link href="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 easily include content 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: snow menu, top, footer) being part of all pages. Once this documetno is updated, all pages will show the modified arch, without either editing one by one.
Thank you all for your help. I thought I was only good with html. I have heard that theoretically it does not give because it is considered that the site was poorly designed so I asked: "But what about a store that is updated products?" and they told me very well that in this case is used programming languages. What you wrote reflects this. Thanks for the help.
– David
Some answers erroneously claim not to be possible, but as I have shown it is only possible with HTML. Simply have the SSI enabled by the web server.
– Daniel Omine