Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linking identical HTML over several pages

Tags:

html

css

How would I link identical HTML used in several pages, instead of adding the same markup in all of the several pages.

like image 540
user1535882 Avatar asked Dec 26 '22 20:12

user1535882


1 Answers

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');
like image 51
pb2q Avatar answered Dec 29 '22 08:12

pb2q