I want to include header and footer in all of my pages. I can include in php by using include() function. But I have only .html file. So is there any html markup to include another html file.
2 Answers
Using HTML Imports
<head>
<link rel="import" href="/path/to/file/file.html">
</head>
And use it with:
var content = document.querySelector('link[rel="import"]').import;
2 Comments
Sa Si Kumar
I tried it. But it hasn't rendered in the browser. But has external file markups added in code view
Corey Young
@sasikumar you still have to insert the content into the dom somewhere. His code only stored it into the content variable. If you have a dom node use this developer.mozilla.org/en-US/docs/Web/API/Node/appendChild if you have text, use .innerHTML.