Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to import HTML into an HTML file?

Tags:

html

I've tried looking for this on here and on google but I haven't really found an answer to this specific question and I'm not sure if there's something - a term or something that I need to look for, so I apologize if this is a commonly asked question.

Either way, let's say for example that I'm building a website with many sections and I wanted these sections to be modular, so each section is it's own html file. So basically I could include this little module anywhere I want on the main html file or maybe I could simply include navbars and footers onto other HTML pages without having to rewrite lines of code.

Is this possible with just HTML alone?

like image 748
jollyjwhiskers Avatar asked Feb 28 '19 11:02

jollyjwhiskers


1 Answers

What you can do is create a php file where you write the html code, and in the index.php call that same file. For exemple:

Tis is your index .php and the file footer.php is the other file with the html that you want.

<html>
<body> 
<h1>Welcome to my home page!</h1>
<p>Some text.</p>
<?php include 'footer.php';?>
</body>
</html>

Or

you can also create an iframe, give it a specific size, in your html file and in the src, you can refer to the html file that you want

<iframe src="../../something.html"></iframe>
like image 51
Luis Luis Maia Maia Avatar answered Oct 27 '22 22:10

Luis Luis Maia Maia