Home arrow Style Sheets arrow Page 4 - CSS Constants
STYLE SHEETS

CSS Constants


One feature designers often wished they had with style sheets are constants –- the chance to define something once and reuse it over and over in the style sheet document. This article shows some techniques for how to achieve that and discusses their pros and cons.

Author Info:
By: Chris Heilmann
Rating: 4 stars4 stars4 stars4 stars4 stars / 19
May 09, 2005
TABLE OF CONTENTS:
  1. · CSS Constants
  2. · The CSS standard compliant approach
  3. · Using ID Selectors and Descendent Selectors
  4. · Moving server side
  5. · Using Server Side Scripting Languages
  6. · More examples
  7. · Parsing CSS with PHP

print this article
SEARCH DEVARTICLES

CSS Constants - Moving server side
(Page 4 of 7 )

There are basically two ways to simulate CSS constants on the server. One involves using the server software and the other involves using scripting languages on the server.

Using Server Side Includes (SSI)

Server Software, like Apache and the Microsoft IIS allow for server side includes (SSI). We can use these to simulate CSS constants.

For Apache, we define a new file extension called “sccs” for “Server Cascading Stylesheets” by adding the following to the configuration file of the server:

 
Options +Includes
AddType text/css .scss
AddHandler server-parsed .scss
 

Inside one of these new “scss” files we can use the Server Side Includes syntax to set and retrieve our constants:

 
<!--#set var="blue" value="#369" -->
<!--#set var="green" value="#363" -->
ul#navigation{
        background: 
<!--#echo var="blue" -->;
        color:#fff;
}
h1{
        border-bottom:1px solid 
<!--#echo var="green" -->;
}

Many Web space providers won’t allow users to change the server configuration, though. What most provide are Server Side Scripting Languages, that can also be used to simulate CSS constants.


blog comments powered by Disqus
STYLE SHEETS ARTICLES

- CSS Padding Overview
- CSS: Margins Overview
- Top CSS3 Button Tutorials
- More Top CSS3 Tutorials for Animation and Im...
- CSS Mega Menus: Adding Extra Sections
- CSS Mega Menus
- CSS3 Accordian Menu: Horizontally Display Hy...
- CSS Combinators: Working with Child Combinat...
- CSS Combinators: Using General Siblings
- Intro to CSS Combinators
- CSS Semicircles and Web Page Headers
- Drawing Circular Shapes with CSS3 and Border...
- More CSS Pagination Link Templates
- CSS Pagination Links
- Animated CSS3 Image Gallery: Advanced Transi...

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 

Developer Shed Affiliates

 




© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials