Including files

Soldato
Joined
6 Mar 2008
Posts
10,085
Location
Stoke area
Hi all,

Current in the process of revamping the dept intranet site from HTML+Tables with JScript to XHTML & CSS (with PHP/JavaScript coming as soon as I learn it).

However, I have built a XHTML/CSS drop down menu using a few guides but it is quite lengthy and I will want this in every file.

How do I go about turning this into an include file and using it in my pages?

I just want to make the code easier to read and get your head around in the future!

Thanks
 
HTML Include files can only be used with PHP or a scripting language. CSS and javascript can be included as part of the HTML, but HTML includes require server side scripting.
 
To add to the above, if you're hosting the site on windows/IIS, you can include it by using...

Code:
<!-- #INCLUDE FILE="includes/my-include.htm" -->
 
if you are wanting to do it in html and php you just need to use:
<?php
include('xxx.php');
?>

at the top of your html documents, where xxx.php is the file with all the header HTML etc. I take it the CSS isnt in the same file as the XHTML for the menus. If it is then you can put that in a style.css file and link to that in the XHTML head of the doc.
 
Last edited:
Thanks, I'll try these and see what happens.

I have an index.html that is styled with style.css, then a menu.html with a dropdown.css.

Well, I have got it all working correctly in one sheet, all the links in my menu work and open in a new tab. Once I get the menu as an include it will really clean the code up.

Although I've learnt the basics several times I've never really used it until now, however I am really enjoying it :D

my only downfall is actually designing the sites and doing the graphical side of it :(
 
It all makes sense after a little while. Look at other sites and see how they work. Some will seem a bit odd and not how you have learnt but if you keep going until you understand you will become a good programmer in general.

Good luck matey.
 
Back
Top Bottom