logo
g Text Version
Beauty & Self
Books & Music
Career
Computers
Education
Family
Food & Wine
Health & Fitness
Hobbies & Crafts
Home & Garden
Money
News & Politics
Relationships
Religion & Spirituality
Sports
Travel & Culture
TV & Movies

dailyclick
Bored? Games!
Nutrition
Postcards
Take a Quiz
Rate My Photo

new
European Travel
Action Movies
Bible Basics
Houseplants
Romance Movies
Creativity
Family Travel


dailyclick
All times in EST

Clairvoyance: 08:00 PM

Full Schedule
g
g HTML Site

BellaOnline's HTML Editor

g

How to use Server-Side Includes

Guest Author - Elizabeth Connick

Does your website have features that are the same on every page, such as a menu or a tagline at the bottom of the page? If so, you can benefit greatly from the use of include files.

Server-side includes are a way to store HTML code in one file that can be accessed by every page on your site. The main benefit to using includes is that you will save enormous amounts of maintenance time. For example, say you have a fifty-page website and you decide to add a new option to the navigation menu. Would you rather go into every single page and add the new item, or make a change to one file and have it instantly appear on every page of your site? If you prefer the second option, read on.

An include file uses the .inc extension (for example, "menu.inc") and can hold pretty much anything you'd use in coding your site – HTML, CSS rules, Javascript, etc. Once you've written up the menu.inc file with your navigation menu, you can call it by placing the following code in each page where you'd like the menu to appear:

<!--#include virtual="menu.inc"-->

Everything to the left of the equals sign tells the browser what to do with the command (basically, "include the following file…" and the information to the right of the equals identifies the specific file to include. If your file is stored in a separate folder on the server, you would write the include call like this:

<!--#include virtual="/_includes/menu.inc"-->

Usually the easiest way to figure out which parts of the page should be set aside as includes is to skim through your site and note which sections appear over and over. The navigation menu is the classic example, but you could also include a header image or footer text. If you've got a sidebar that appears on multiple pages, it's also a candidate for an include file. To build the include file, just grab the HTML code for that section and paste it into the include file. You don't need any other code, like a or section – the include file isn't a page in and of itself, just a piece of one.

If you do decide to use includes you'll need to use the .shtml extension for every page that uses an include file, rather than using the standard .html extension. Using .shtml won't change anything about the pages or how the code works; it simply enables your web server to use include files.
This site needs an editor - click to learn more!

Add How+to+use+Server%2DSide+Includes to Twitter Add How+to+use+Server%2DSide+Includes to Facebook Add How+to+use+Server%2DSide+Includes to MySpace Add How+to+use+Server%2DSide+Includes to Del.icio.us Digg How+to+use+Server%2DSide+Includes Add How+to+use+Server%2DSide+Includes to Yahoo My Web Add How+to+use+Server%2DSide+Includes to Google Bookmarks Add How+to+use+Server%2DSide+Includes to Stumbleupon Add How+to+use+Server%2DSide+Includes to Reddit




RSS | Related Articles | Editor's Picks Articles | Top Ten Articles | Previous Features | Site Map


For FREE email updates, subscribe to the HTML Newsletter


Past Issues


print
Printer Friendly
bookmark
Bookmark
tell friend
Tell a Friend
forum
Forum
email
Email Editor


Content copyright © 2014 by Elizabeth Connick. All rights reserved.
This content was written by Elizabeth Connick. If you wish to use this content in any manner, you need written permission. Contact BellaOnline Administration for details.

g


g features
What's Coming in HTML 5

What is FTP?

HTML Fundamentals - Tables

Archives | Site Map

forum
Forum
email
Contact

Past Issues
memberscenter


vote
Poetry
Daily
Weekly
Monthly
Less than Monthly



BellaOnline on Facebook
g


| About BellaOnline | Privacy Policy | Advertising | Become an Editor |
Website copyright © 2014 Minerva WebWorks LLC. All rights reserved.


BellaOnline Editor