N. Chalifour N. Chalifour - 1 year ago 60
PHP Question

Navigation bar in html5

I have a quick question. I'm wondering if it is possible to have a external html file with my navigation bar in it and have that be put in to all of my pages for my website. If so how do I do this? I have tried using these methods:

<script rel="import" src="navigation-bar.html"></script>


but so far neither of them have worked... Do I have to use PHP and if I do how do I implement this.

please help.

Answer Source

I would use PHP to do this.

Here is the structure of how it would work.

 <?php require('/directory/to/your/header.php'); ?>
   ...Your Content Here

In a separate header.php file you would include your navbar.


   echo '...enter your Navbar HTML code';

Your file will have to have the extension .php and every time you write in php, you must start and end with

    ...enter your php code...

You can mix php with html simply by writing the php into the HTML. Take for example the following href:

 <a href = "<?php echo 'www.yourlinkhere.com'?>">Your link Name</a>

For more information please refer to : http://php.net/manual/en/

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download