A Hyperlink Icon An Include File is basically a commonly used file or section of code or division, such as a navBar or mastHead or Footer that can be added or included to each of your Web site pages so that it can be reused over and over. Include files allow you to use modules that can make the code of your main pages appear smaller and easier to read. But more importantly, any changes made to the include file will be quickly and easily propagated throughout the entire web site without having to edit every single page.

A single line of script, from Server Side scripting languages such as PHPPHP

PHP is a free server-side scripting language originally designed for web development to produce dynamic web pages. PHP code can be embedded into the code of a normal HTML Web page. PHP originally was an acronym for "Personal Home Page." However, it is now commonly referred to as "Hypertext Preprocessor."

PHP files have a .php file name extension.
, ASPASP

ASP or ASPX are file extensions for an ASP.NET Active Server Pages. It's a scripting language or web technology used on Microsoft servers running Internet Information Services.

ASP files have an .asp or .aspx file name extension.
, Cold FusionCold Fusion

Cold Fusion is a full and powerful scripting language now owned by Adobe, and integrated with Dreamweaver.

Cold Fusion files have a .cfm file name extension.
, or SHTMLSHTML

SHTML stands for Server-parsed HyperText Markup Language, which allows simple server side commands, such as Server Side Includes.

SHTML files have .shtml, .shtm, or .stm file name extensions.
, is used within the main pages to call the include files. Each of your main pages will have to be renamed with the scripting language's extension, for instance index.php, portfolio.php, and contact.php. Include files are Server SideServer Side

Server Side refers to files that are run remotely on the host server, instead of on the local "Client Side" computer. PHP and ASP are examples of Server Side scripting languages. JavaScript in an example of a Client Side scripting language, which can be viewed on a browser on a local computer.
and the scripting language must be installed on the remote server. Include files do not run, that is they normally cannot be viewed on the local browser from the client side, or local machine unless you install special software on your local computer. Consequently, it is recommended that you do NOT use include files unless you have a lot of pages that will call them. If you only have a five or six page site, it probably is not worth the effort.

Rule one: Your remote server must support PHP, or Cold Fusion, or ASP, or SHTML. Most hosting companies support PHP and SHTML, but call your provider and confirm. (Or upload a very small .php test file that calls an include file, and also upload the include file to confirm.)
Most Windows based hosting sites support ASP or ASPX, but call your hosting provider and confirm.
Many companies, such as GoDaddy, may have a modest yearly charge for Cold Fusion (.cfm).

Rule two: All files calling the include file, such as your index page, your Portfolio page, your Contact page, must have a .php extension, or .cfm, or .shtml, or .asp (but do not mix scripts and extensions).

Step 1a. Create your Include File
For instance, build the Nav Bar shown below, (navBar.htm) or MastHead (mastHead.htm)...
(Note: there is no other code needed for navBar.htm, only the four lines of code shown below.)

<a href="index.htm">Home</a> |
<a href="resume.htm">Resume</a> |
<a href="portfolio.htm"/>Portfolio</a> |
<a href="contact.htm">Contact Me</a>
Step 1b. Save the include file as an .htm, .php, .cfm, or .asp, or aspx file.
ex: navBar.htm or navBar.php (but the include file does not have to have the script extension, such as .php or .asp). You may choose to name include files .htm so that you can easily view them both locally and remotely.
The actual include file does not include <html> or <head> or even <body> tags. You basically just cut out the code you want (such as the navBar section of a web page that will be used over and over) and save it as a file called something like navBar.htm

Step 2a. Create your Content pages, such as index.php, portfolio.php, and contact.php...
Step 2b. Call the Include file from your Content pages:
For instance, in the exact area where you used to have the navBar tags and code add:

ex: <?php include ("navBar.php"); ?> (PHP)
ex: <cfinclude template="navBar.htm"> (Cold Fusion, CFM)
ex: <!--#include file="navBar.htm"--> (SHTML)
ex: <!--#include file="yourfilename.asp" --> (ASP)

Step 3. Upload all the files to the Web site. That is upload: navBar.htm and the files that call it, such as index.php and contact.php, or index.cfm and contact.cfm

Note 1: When you view the source remotely online (at the server side) both files (navBar.htm and index.php) are displayed as one file. A person who chooses View > Source from the browser cannot tell whether or not an include file is used.

Note 2: You can locally view each of the include files on your desktop browser (such as navBar.htm) on your computer if you give them .htm extensions. However, you cannot view .php, .cfm, or .asp files locally on your desktop browser without special software installed on your computer.

For more HTML code samples see: www.w3schools.com
For other resources and tutorials see: quackit.com and htmlquick.com
ValidateValidate

Validation checks the syntax of your file, looking for both errors and possible issues when viewing your page in a browser. Some of the problems reported are missing end tags, missing characters, invalid attributes, incorrect nesting of elements...
 your file, see: http://validator.w3.org

Review Assignment Learning Project: 10 Practice Review Steps

Return to Menu   Top