W3C home > Mailing lists > Public > www-style@w3.org > April 2005

Re: User constant declarations in style sheets

From: Werner Donné <werner.donne@re.be>
Date: Mon, 25 Apr 2005 09:46:10 +0200
Message-ID: <426CA042.4080608@re.be>
To: w3cstyle@karsites.net
CC: www-style@w3.org

I'm in favour of constants, because the only symbolic values
we have today are relative values such as "em". Imagine you
want to keep your text in phase. It would then be natural to
express heights in terms of the leading, which would be itself
derived from the font size with a factor. At the moment this
factor would have to be repeated all over the style sheet.

I would not introduce variables because then you also need something
to make them vary, i.e. some sort of assignment. This would create
a different language. Constants, on the other hand, can be replaced
by their value.

Werner.

w3cstyle@karsites.net wrote:
> Hi there.
> 
> I was wondering if it would be possible to implement the 
> declaration of constants and/or variables at the head of 
> each external and internal style sheet.
> 
> Eg. for positioning div blocks, instead of having to hard 
> code the top: and left: property value in each rule 
> declaration, what about something like this:
> 
> /* start of style sheet */
> 
> CONST: top_value = 200px, left_value = 20%, 
>        col_width = 20%, another_val = 2.5em;
> 
> VAR: my_fav_color = blue, cool_border_color = white,
>      dd_menu_top = 89px, left_margin_width = 30px,
>      spacer_value = top_value + 30px;
> 
> /* end of CONST and VAR declaration block */
> 
>  #top_logo {
>   /* display: block; item is visible */
>   /* display: none;  item is NOT visible */
>   display: block;
>   position: absolute;
>   top: 5px;
>   left: 1%;
>   right 1%;
>   width: 98%;
>   height: 80px;
>   border: 1px solid red;
>   background-image: url(./triplegears.jpg);
>   background-position: 250px;
>   color: white;
>   text-align: center;
>  }
> 
>  #left_nav_menu {
>   display: block;
>   position: absolute;
>   top: dd_menu_top;   /* uses a user-defined variable */
>   left: 1%;
>   width: 20%;
>   border: 1px solid red;
>  }
> 
>  /* anchor links in menus */
> 
>  #left_nav_menu a {
>   display: block;
>   color: my_fav_color; /* user-defined variable */
>   background-color: transparent;
>   text-decoration: none;
>   font-weight: normal;
>   margin: 2px;
>  }
> 
>  #right_column {
>   /* display: block; item is visible */
>   /* display: none;  item is NOT visible */
>   display: block;
>   position: absolute;
>   top: dd_menu_top;   /* user-defined variable */
>   right: 1%;
>   width: 20%;
>   widht: col_width; /* user-defined variable */
>   border: 1px solid red;
>  }
> 
> So changes to the value dd_menu_top, for example,  are made 
> in one place, at the start of the style sheet. These changes would 
> then be reflected through the rest of the style sheet.
> 
> So. if I wanted position a drop down menu system at a 
> certain absolute pixel value on a page, all I need to do is 
> to change the value assigned to dd_menu_top variable, at the 
> start of the style sheet.
> 
> Is this feasable in CSS 3?
> 
> Kind Regards - Keith Roberts
> 
> http://www.karsites.net/
> 
> SPDTool - an idea for a structured open source development
> CASE tool. Find out more at the above link!
> 
> 
> 
> 

-- 
Werner Donné  --  Re BVBA
Engelbeekstraat 8
B-3300 Tienen
tel: (+32) 486 425803	e-mail: werner.donne@re.be
Received on Monday, 25 April 2005 07:46:15 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 27 April 2009 13:54:36 GMT