How would I link identical HTML used in several pages, instead of adding the same markup in all of the several pages.
You can do this using an iframe
on each of the several pages, with the src
being the common HTML.
It also is possible on the client-side using javascript. jQuery makes this particularly easy providing a load
method. You can use jQuery.load()
to add an HTML block into elements across different HTML pages.
As an example, if every one of the pages has an div
named content
:
<div id=`contents`></div>
Then you could do this in each page:
$('#content').load('commonContent.html');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With