homepage Welcome to WebmasterWorld Guest from 54.145.183.190
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / CSS
Forum Library, Charter, Moderators: not2easy

CSS Forum

    
CSS tags to insert same header and footer into multiple pages?
nadsab

10+ Year Member



 
Msg#: 4400702 posted 11:52 pm on Dec 22, 2011 (gmt 0)

Hi,

I forgot the syntax or tags for this, what tags do I use to create and edit just one master page with headers and footers on it, so that I can just edit that one page and have all my changes to headers and footers appear on multiple pages across the site?

Thanks

 

Skier88

5+ Year Member



 
Msg#: 4400702 posted 1:36 am on Dec 23, 2011 (gmt 0)

Technically you can use :before and :after, but that's a bad idea for a number of good reasons. The "correct" solution would be some form of server-side scripting, like PHP.

lucy24

WebmasterWorld Senior Member lucy24 us a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month



 
Msg#: 4400702 posted 1:47 am on Dec 23, 2011 (gmt 0)

Yes, I think "before" and "after" were really intended for things like quotation marks or brackets.

That's assuming you are asking about headers and footers with actual text content. If it's just a background image, then of course you can easily put that in your CSS.

tvirus



 
Msg#: 4400702 posted 4:28 am on Dec 23, 2011 (gmt 0)

i think what you are aksing doesn't happens with CSS. the :before , :after can only help elements.
You can create a header.htm and footer.htm
and then you can use server-side include to do the job

PHP
<? include 'header.htm'; ?>

HTML
<!--#include file="header.html" -->


Remember, this won't work offline on your PC. run it on some server. Try WAMP server for windows

rocknbil

WebmasterWorld Senior Member rocknbil us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 4400702 posted 5:20 pm on Dec 23, 2011 (gmt 0)

Slight correction - SSI's will only work if you add .html and/or .htm for parsing html files. By default, only .shtml files are parsed with SSI. details in post #4383542 [webmasterworld.com].

Use file if the include is in the same directory, virtual if it's in some other directory than the current directory.

tvirus



 
Msg#: 4400702 posted 6:23 pm on Dec 23, 2011 (gmt 0)

I stand corrected.

lucy24

WebmasterWorld Senior Member lucy24 us a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month



 
Msg#: 4400702 posted 12:05 am on Dec 24, 2011 (gmt 0)

Way cool :) In the linked thread you said ".htaccess". Does that mean you can reasonably expect it to work if you're on shared hosting?

:: still looking for an idiot-level include that you can pass a variable or two, so it will make a different footer (such as a page-specific menu in a consistent format) for each page ::

mack

WebmasterWorld Administrator mack us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 4400702 posted 3:45 am on Dec 24, 2011 (gmt 0)

Htaccess should generaly work on shared hosting, best bet is to ask your host if its something they allow.

I think a server side language is still the best way to go about it. Php includes would be perfect for your situation.

Mack.

rocknbil

WebmasterWorld Senior Member rocknbil us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 4400702 posted 6:14 pm on Dec 24, 2011 (gmt 0)

If your shared host doesn't allow basic .htaccess directives, it's time for another host! :-)

Php includes would be perfect for your situation.


It will work, but I wouldn't say perfect. PHP is a rich server side scripting language, to use it just for basic includes is overkill. Additionally, you have to mod the server to parse all .html/.htm files as PHP, which can give you some unexpected results - or change your files to .php extensions, which means you have to address SEO issues for existing pages (i.e., all your URLs have now changed and you need to 301 the old ones.)

so it will make a different footer (such as a page-specific menu in a consistent format) for each page


No code samples handy, but yes you can do this, and can even reflect "the current page" via environment variables. An easy way to do the first is just change the directive to point to different footers.

Parsing html as SSI has a lower overhead and it's the right tool for the job - not perfect either, but closer. :-)

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / CSS
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved