Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Including header file using HTML

HTML header

  • Please log in to reply
43 replies to this topic

#1 SharonB

SharonB

    CC Lurker

  • Just Joined
  • Pip
  • 3 posts

Posted 30 March 2008 - 10:45 AM

Is it possible to include a header and footer file using HTML? I have my file as a .html and need to be able to include the HTML for the header and footer. Anyone know how I can do this?
  • 0

#2 chili5

chili5

    CC Mentor

  • Expert Member
  • PipPipPipPipPipPipPipPip
  • 3038 posts
  • Programming Language:Java, C#, PHP, JavaScript, Ruby, Transact-SQL
  • Learning:C, Java, C++, C#, PHP, JavaScript, Ruby, Transact-SQL, Assembly, Scheme, Haskell, Others

Posted 30 March 2008 - 12:27 PM


<?php
include("header.html");
?>

<?php
include("footer.html");
?>


header.html



<H1 ALIGN=CENTER>Welcome</H1>


footer.html


Copyright © 2008


I don't know how to do this without PHP but this should be what your looking for. :)
  • 0

#3 TcM

TcM

    CC Mentor

  • VIP Member
  • PipPipPipPipPipPipPipPip
  • 7563 posts

Posted 30 March 2008 - 02:40 PM

That is PHP, not HTML. And I think that is the only way to go, to do this with html you have to use frames, and that's not recommended.
  • 0

#4 chili5

chili5

    CC Mentor

  • Expert Member
  • PipPipPipPipPipPipPipPip
  • 3038 posts
  • Programming Language:Java, C#, PHP, JavaScript, Ruby, Transact-SQL
  • Learning:C, Java, C++, C#, PHP, JavaScript, Ruby, Transact-SQL, Assembly, Scheme, Haskell, Others

Posted 30 March 2008 - 02:52 PM

I know it's PHP, but itgets the job done, I don't think it's possible with HTML.

You could use frames but that's not recommended.
  • 0

#5 v0id

v0id

    Retired

  • Retired Mod
  • PipPipPipPipPipPipPipPip
  • 2313 posts

Posted 30 March 2008 - 08:52 PM

You cannot include other files in plain HTML. You can do it using SSI though.
<!-- my_include_file.html -->
Hello, World!
<!-- my_main_file.shtml (note the s-) -->
<!--#include file="my_include_file.html" -->
Other content here...

  • 0
If you enjoy reading this discussion and are thinking about commenting, why not click here to register and start participating in under a minute?

#6 chili5

chili5

    CC Mentor

  • Expert Member
  • PipPipPipPipPipPipPipPip
  • 3038 posts
  • Programming Language:Java, C#, PHP, JavaScript, Ruby, Transact-SQL
  • Learning:C, Java, C++, C#, PHP, JavaScript, Ruby, Transact-SQL, Assembly, Scheme, Haskell, Others

Posted 31 March 2008 - 01:58 AM

Isn't that almost the same thing as using PHP?

Which one would be better PHP includes or SSI?
  • 0

#7 John

John

    CC Mentor

  • Moderator
  • 4450 posts
  • Location:New York, NY

Posted 31 March 2008 - 09:51 PM

Isn't that almost the same thing as using PHP?

Which one would be better PHP includes or SSI?


I believe it does the same thing as your php, but perhaps the server doesn't have PHP enabled in which case using SSI would be the only option [assuming the server allows SSI]
  • 0

#8 Guest_Kaabi_*

Guest_Kaabi_*
  • Guest

Posted 05 May 2008 - 04:43 PM

I used to use a header and footer on my old website all the time. It makes things a lot easier, with the <php_include> and such.
  • 0

#9 Xav

Xav

    CC Mentor

  • VIP Member
  • PipPipPipPipPipPipPipPip
  • 8356 posts

Posted 06 May 2008 - 04:33 AM

You can'y use PHP unless your site is actually hosted online - if you're just making local pages, then it won't work. Also, some web development software doesn't show it up on the designer.
  • 0
If you enjoy reading this discussion and are thinking about commenting, why not click here to register and start participating in under a minute?

#10 John

John

    CC Mentor

  • Moderator
  • 4450 posts
  • Location:New York, NY

Posted 06 May 2008 - 08:44 AM

You can'y use PHP unless your site is actually hosted online - if you're just making local pages, then it won't work. Also, some web development software doesn't show it up on the designer.


Every piece of php code I have ever written was written and tested locally.
  • 0

#11 chili5

chili5

    CC Mentor

  • Expert Member
  • PipPipPipPipPipPipPipPip
  • 3038 posts
  • Programming Language:Java, C#, PHP, JavaScript, Ruby, Transact-SQL
  • Learning:C, Java, C++, C#, PHP, JavaScript, Ruby, Transact-SQL, Assembly, Scheme, Haskell, Others

Posted 06 May 2008 - 11:43 AM

If you have web server software on your computer, you can test locally. All my PHP code I test locally.
  • 0

#12 Xav

Xav

    CC Mentor

  • VIP Member
  • PipPipPipPipPipPipPipPip
  • 8356 posts

Posted 06 May 2008 - 12:24 PM

How? I've never managed it - what software should I use?
  • 0
If you enjoy reading this discussion and are thinking about commenting, why not click here to register and start participating in under a minute?





Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download