1

Instead of copying and pasting this same code into multiple pages I want to make a html file and then paste the code there and link all the pages to that one file to get the links. Is this possible??

Example of code

my code is

<a href="WebPage1.html"><img src="button1.png" onmouseover="this.src='buttonA.png'" onmouseout="this.src='button1.png'"></a>

<a href="WebPage2.html"><img src="button2.png" onmouseover="this.src='buttonB.png'" onmouseout="this.src='button2.png'"></a>

<a href="WebPage3.html"><img src="button3.png" onmouseover="this.src='buttonC.png'" onmouseout="this.src='button3.png'"></a>

What I'm trying to get

<link rel="WebNavigation.html"> ? 

Something along those lines, I'm trying to use one line of code instead of 3

User1264
  • 13
  • 4
  • In HTML doesn't exists includes, it's an experimental functionality. You need to use a programming language like javascript or php – Marcos Pérez Gude Jun 27 '16 at 09:46
  • This is not possible with HTML. You can achieve this with PHP or a number of other templating engines using include statements. – Joey M-H Jun 27 '16 at 09:46

1 Answers1

1

<?php include("your file location"); ?> This should do the work using php.

e.g.

<div class="web-nav">
  <?php include("WebNavigation.html"); ?>
</div>

You need some knowledge in php programming if you want to achieve your desired result.

Cookie Ninja
  • 1,156
  • 15
  • 29
  • Thanks; is there a method of doing this using JavaScript? – User1264 Jun 27 '16 at 09:55
  • I believe that these is much more useful. Since files will be uploaded to the server, php is much needed because it is a `server-side` language. Javascript on the other hand `client-side`. Much more useful for page manipulation, animations, sending requests, etc. – Cookie Ninja Jun 27 '16 at 10:02