In my project, I have several pages with the same structure (header, menu, etc)
Can I make an external HTML file with a repeating part of my code and just some kind of insert code from the external file to the current HTML code as a part of it?
Hi, from my humble understanding it is possible to avoid duplicating (or copy/paste) code with the help of JavaScript or server side language. Check out this search for a start: html code duplicate in multiple pages - Search (bing.com)
1 Like
Hi!
Thanks for the advice, but I’m a new guy here, just started learning HTML and CSS. JS is next
by my understanding of HTML you can write code in external file and link it in header section like we link Sylesheet
I’ve already done that using PHP. It’s pretty simple. If it help you, just google for ‘include’ or ‘require’ PHP statement. Basically they allow you to load different files on the same HTML file. The syntax is something like:
include '*filename* ';
or
require '*filename* ';
and you’ll add this statement where you like the file to be load.