Hi all,

I'm quite rusty at this but volunteered to build a site.

Although this will be a momentary quick fix to have a site running, I'd like to have the menu fetched from a different html file which I already created but somehow it doesn't show.

The menu lays in "menu.html" and has css all in one file within the same folder as "index.html". I can open it in my browser and it loads ok.

The problem is inserting it in the body of the website (index.html). I am using <a href="menu.html"> inside the body but it fails to show it.

I can see the menu only if I put all the css and html code inside the same page which down the road will be a pain when trying to modify it.

Can someone tell me how to properly contain the entire menu bar in a separate html file and which is the correct tag to insert it inside the website's pages?

Thank you!

If you want to seperate the sections of your code, you will need to use PHP and include the files.

<?php include('header.php'); ?>

<?php include('menu.php'); ?>

<?php include('footer.php);>

you can not do this with html files.

Member Avatar for diafol

If you don't use a server-side language like php, you always have SSI (server side includes) - a bit old tech now, but it still works on most servers Apache, IIS etc.

However, it does mean that the pages using SSI must have a special html extension, e.g. .shtml, .stm or .shtm

Here's one I made earlier and it works fine:

index.shtml

<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>shtml test</title>
</head>

<body>
<!--#include file="footer.html" -->
</body>
</html>

footer.html

<p>SAY HELLO</p>

I get "SAY HELLO" when I load index.shtml.

SSI was my first foray into web tech back in the early 90s. SSI does a lot more than just this - see http://en.wikipedia.org/wiki/Server_Side_Includes for an intro

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.