[HTML] Identical content over multiple pages?

LurkerAspect

Now officially a Super Lurker
Reaction score
118
Hi there :D

I've recently started learning how to make websites with HTML and CSS for university/college, and I was wondering if it's possible to import a specific area of code that I can define outside the website, and use across multiple webpages? In other words, is it possible to create an external file with a few lines of code, then import that snippet of code into multiple web pages?

Basically I'm making a website with 16 pages, and I don't want to have to modify the navigation bar's links for every single page, which means making about 16 links for 16 pages, which comes out to 256 links I'll need to type out/copy-paste.

If you're still confused, I'll try to illustrate: Here's the code snippet:
Code:
<div id="quicklinks">
     <a href="pg1">Home</a>
     <a href="pg2">Accomodation</a>
     <a href="pg3">Entertainment</a>
     <a href="pg4">Shopping</a>
</div>
I want to be able to import this snippet so I don't have to write it out again on every single page. Is that possible?

Any help is greatly appreciated :D
 

UndeadDragon

Super Moderator
Reaction score
448
The best way will be, if your server supports PHP, to include the file everytime it is needed and then you will update the single file when needed, which will affect all pages it is included on.

For example:

navigation.htm
PHP:
<div id="quicklinks">
     <a href="pg1">Home</a>
     <a href="pg2">Accomodation</a>
     <a href="pg3">Entertainment</a>
     <a href="pg4">Shopping</a>
</div>

index.php
PHP:
<html>
<head>
<title>Test</title>
</head>

<body>
<?php include "navigation.htm"; ?>
</body>
</html>
 

LurkerAspect

Now officially a Super Lurker
Reaction score
118
Thanks Undead Dragon, I'll give it a shot :D so far the website is not going live, it'll just be run locally for marking purposes so I'm sure the PHP won't be a problem :) Thanks for the speedy reply!
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top