Reputation: 3
I didn't really know how to phrase this question but this is what I'm trying to ask. How can I make it so that this block of code is on every page but I only have to edit the original block of code so that it changes on all pages?
<ul class="horizontal" id="nav">
<li><a href="#" class="active">About Us</a></li>
<li><a href="#">Our Products</a></li>
<li><a href="#">FAQs</a></li>
<li><a href="#">Contact</a></li>
<li><a href="#">Login</a></li>
</ul>
Upvotes: 0
Views: 42
Reputation: 4010
Use PHP. Then you can create a file called (for example) header.php
In header.php:
<ul class="horizontal" id="nav">
<li><a href="#" class="active">About Us</a></li>
<li><a href="#">Our Products</a></li>
<li><a href="#">FAQs</a></li>
<li><a href="#">Contact</a></li>
<li><a href="#">Login</a></li>
</ul>
Then on any page you want to include this section you can simply write:
<?php include 'header.php'?>
In place of where you would have put this block of code. Any changes to header.php will update on any pages using it.
For example:
<html>
<head>
<title>My page</title>
</head>
<body>
<h1>My page</h1>
<?php include 'header.php'?>
<img src='image.png'/>
<p>This is my webpage</p>
</body>
</html>
Upvotes: 1