0

I have a multi page website which uses the same navbar and everytime I want to change something to it I have to copy and paste everything that I have done to the other HTML files.Is there a way to have only one file where the code for the navbar is located and just import it to the other HTML files so when I change something to it, it also changes to all the other files ? (much like a React Component)

Mudu
  • 91
  • 5
  • 1
    Are you asking how to use [the script element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script)? – Andy Oct 01 '21 at 16:47
  • What have you tried? There's no native HTML way to do this, but you can [find hacks](https://www.w3schools.com/howto/howto_html_include.asp) that achieve what you're describing. – user1717828 Oct 01 '21 at 16:52
  • Does this answer your question? [Include another HTML file in a HTML file](https://stackoverflow.com/questions/8988855/include-another-html-file-in-a-html-file) – Heretic Monkey Oct 01 '21 at 16:54

1 Answers1

0

Answer is "Yes" you can do it without React also. Look for the previous version of w3.js

see this example of how they are including

https://www.w3schools.com/howto/content.html

into another page

here is the existing working sample

https://www.w3schools.com/howto/tryit.asp?filename=tryhow_html_include_2

Negi Rox
  • 3,828
  • 1
  • 11
  • 18