• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

++HTML Gurus!! I have a question...

Electric Amish

Elite Member
Is there a way to create a single header and/or footer that is displayed on every page of a site? So that if I ever had to make a change I'd only have to make it once instead of on every page??

tia

amish
 


<< You can do it with style sheets I think. It's been a while since I messed around with any of that. >>


Stylesheets can't do that.
 
You can either use asp or php to include the files or you could use the server side includes that apache and I think other web servers have that too.

I only know how to do it in php
<?php include("header.php"); ?>

just look up server side includes.
 


<< Is there a way to create a single header and/or footer that is displayed on every page of a site? So that if I ever had to make a change I'd only have to make it once instead of on every page??

tia

amish
>>


As tedious as it sounds, yes, that's the only way to do it.

You have to rely on the server. i.e. SSI

Or use a program that does a batch edit of your HTML pages.
 


<< i was under the impression that cascading style sheets were capable of doing that, oh well 😕 >>



nah, css is for formatting, not content.
 
i think the easiest way would be to create two javascript files,
one called header.js and the other footer.js.

inside the files, create your headers and footers,

i.e. document.write('blah.. this is where the code for the header goes');


ANd in your real html pages, just link to those javascript pages. It works, cuz I've done it before.

that would probably be the easiest way without learning asp,etc.

 


<< i think the easiest way would be to create two javascript files,
one called header.js and the other footer.js.
>>



my knowledge of javascript is minimal, so forgive me if i'm wrong, but wouldn't this result in 3 calls to the server? if speed is a concern, i would go for SSI, since that's server side... though you're right, it is probably the easiest.
 
yeah... SSI would be good to use. But the thing is that SSI is not available to everyone, especially those who use free hosts.
 
just thought of something else.

you can always use frames.
one frame for the header. Then the middle frame should contain the body of the page. And finally the last frame should contain the header.

This will alleviate the issue of accessing the server so much. The pages might also load a little faster. But remember that not everyone likes frames and you should take into account the screen sizes that people have.

But it should work for all types of servers and there is no javascript or other crap involved. Just pure html.

hope it helps.
 
That can easily be done with PHP. Make the file, for example header.php. And use the php require code where you want the header to be on ever page. So when you update header.php it will be updated on every page you used
 


<< my knowledge of javascript is minimal, so forgive me if i'm wrong, but wouldn't this result in 3 calls to the server? >>



If the .js files are used on every page, they'll become cached real fast and save the end user
from downloading a ton of HTML. I always use a .js file for mouseover declarations. The only
problem you would run into with .js files is if the moron visiting your site has Javascript turned
off... of course, you could probably just place an HTML-lite text-only header and footer in
between <NOSCRIPT></NOSCRIPT> tags.

SSI and PHP would probably be the cleanest way to do what you want - if your server supports it.
 
Back
Top