Question:

Can you load links from an external file with only HTML & CSS so only that file has to be updated for changes?

by  |  earlier

0 LIKES UnLike

I am designing a new website and I know in the future I am going to have to add more links or take some away.

Every page will have the same main navigational menu at the top.

So with that I thought it would be really handy if there was a way to store the links in one file so I only have to update that single file and not every page to change the links.

I am only using html and css, and my knowledge is a bit limited to what css can do (I've just started learning the self taught way).

Does anyone have any suggestions to how I can this?

 Tags:

   Report

4 ANSWERS


  1. try linkink it to a pdf and then you just need to change the pdf.


  2. Hmmm...

    I'm not sure if you can do this only utilizing HTML. However, if you are able to use a server side language like PHP or ASP then you could place your link menu in a file, we'll call it menu.php, then include that file into each page where you want the menu to display.

    Why this is useful:

    Including a file means you only have to make changes to that single file, in this case the menu.php file, to make site wide changes to your link menu. It severely cuts down on website maintenance time and frees you up to do other things...

  3. Yep, do a virtual include:

    <!--#include virtual="YOURFILEwithLINKS.html" -->

    This can be inserted right into the page where you want the links to show up. Also, make sure the file that you plan on putting this virtual include is saved as an SHTML file (yourpage.shtml), else it won't work. And it will only show up once it's uploaded onto a test server. Trying to see it from your desktop, it won't show up.

  4. You can't do this with just HTML or CSS. Storing information as you described is commonly done with server-side scripting and external files or, preferably, a database.

    For example, you could conceivably use PHP on your site, and have it fetch the links from a data table or even just a flat file.

    Or, even simpler, you could build a PHP variable that includes all the HTML you need to display your common content. You can code the URLs in that script, and then call it for each page. When you make one change, it shows up everywhere.

    Unfortunately, HTML isn't designed to be dynamic, so you need some external thing to load repeating content. CSS is strictly for style and layout. URLs are content. CSS is meant to keep them separate.

    You can probably do something like this in JavaScript as well, but I'm a server-side guy.

Question Stats

Latest activity: earlier.
This question has 4 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.