1. Computing & Technology

Discuss in my forum

"How do I Use CSS Includes to Include Content on my Website?"

By , About.com Guide

See More About:
Question: "How do I Use CSS Includes to Include Content on my Website?"

CSS seems like a logical place to store repeating content like copyright dates and navigation. But unfortunately, CSS is not intended to be used to store content. Instead, CSS provides the styles for the content rather than the content itself.

Answer:

The short answer: You can't. While you can use an external style sheet to define the styles for every page on your site, you can't place content in that style sheet to be displayed on every page. CSS is not intended for content, but only for the styles or look-and-feel of your site.

Server Side Includes Can Do the Job

While you can't do it with CSS, there are other tools that you can use to write your website content once and use it in multiple locations. The oldest method is Server Side Includes (SSI) or SHTML. When you use SSI, you write the repeating content in a separate file and then call that file from within your HTML with an SSI directive. But this will only work if your server supports SSI.

Other Includes

If you don't have SSI or just don't want to use it, you can use other methods to include one HTML file in another. Tools like PHP or ColdFusion or ASP or even JavaScript. It's also possible to use a content management system (CMS).

©2012 About.com. All rights reserved.

A part of The New York Times Company.