Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: Web Development
Expertise: Beginner
Dec 22, 1999



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Apply Web Site Templates Using Includes

I want to create a consistent look and feel to my site. Without using frames, how do I apply a template to all my Web pages that will include a navigation bar on every page? What happens when I want to make a change to the navigation bar? Do I have to go to every single page? Cascading Style Sheets (CSS) only allow me to provide consistent formatting, but what about the navigation bar and images?


One useful and popular way to create a reusable navigation bar is to create a file that contains only your navigation bar. Do not include tags like or —just the HTML required to make the bar itself. When you have done that, you can use an "include" tag to display that toolbar in your pages. Any time you make a change to your new toolbar file, that change will be reflected in all of the pages that have the "include" tag. The syntax for the tag looks like:

Just drop that tag in your page anywhere you want to show your navigation bar. Keep in mind that the links that are in the navigation bar must be valid from every page in which the "include" is used. A simple strategy is to use a single folder for all files in your site. If done that way, there will probably be very few "path" problems. It doesn't have to be done that way, but just use common sense with regard to the links in your navigation bar.

DevX Pro
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date