+ 3
Can I reference a html file inside html?
I want to make a website and have a header/footer, I was wondering if I could write it once in one file and call it in another
7 Answers
+ 3
In additional to Toni Isotalo's answer:
<?php include"file.html"?>
or
<?php fopen"file.html?>
file.html
Your code to call, can either be php, js, txt, xml, json etc..etc.. extensions
Personally I use always include:
https://secure.php.net/manual/en/function.include.php
Edit: Make your main file .php, since .html will not work with php code unless it is a .php extension. html will work in .php extensions
+ 3
You can do it with HTML <frame> or <iframe> tags. You can do it with a host scripting language like PHP or ASP. You can do it with a Java Applet within HTML. Or you can do it with JavaScript within HTML.
+ 2
Not with html but I always do that with php or even better with laravel.
+ 1
Yes. With iframes.
https://www.w3schools.com/html/html_iframe.asp
+ 1
y'all beat me to the iframes
0
Ofcourse
- 2
href="/yourwebsite.html"