HighDots Forums  

'Define' functionality in CSS?

Cascading Style Sheets Layout/presentation on the WWW (comp.infosystems.www.authoring.stylesheets)


Discuss 'Define' functionality in CSS? in the Cascading Style Sheets forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Jonathan Brady
 
Posts: n/a

Default 'Define' functionality in CSS? - 08-14-2003 , 02:53 PM






I couldn't find this anywhere so I'm not sure that it exists.

In most programming languages, one can define a value and then uses that
value by referencing the name in all of the source, and if that value
needs to be changed, then it's a simple matter of changing the
definition, and the change will be reflected of course throughout the
whole thing.

Example:

#define d_length: 20;

and then use 'd_length' in functions instead of typing 20. If you change
the definition then the value changes throughout.

I would like to be able to do something like:

#define color_1: red;
#define size_1: 0.9em;

p {
background-color: color_1;
font-size: size_1;
}
h1 { background-color: color_1; }

td {
width: 20px;
font-size: size_1;
}

This could come in very handy in creating similar stylesheets to create
various schemes.

Is there something like that in CSS and I missed it somehow, or is such
functionality non-existant in CSS?

--
J Brady


Reply With Quote
  #2  
Old   
Steve Pugh
 
Posts: n/a

Default Re: 'Define' functionality in CSS? - 08-14-2003 , 03:28 PM






Jonathan Brady <jbrady (AT) removethisspamkiller (DOT) myfmail.com> wrote:

Quote:
In most programming languages, one can define a value and then uses that
value by referencing the name in all of the source,
True, but...

Quote:
Is there something like that in CSS and I missed it somehow, or is such
functionality non-existant in CSS?
CSS is not a programming language.

Use a programming language to output your CSS.

Steve

--
"My theories appal you, my heresies outrage you,
I never answer letters and you don't like my tie." - The Doctor

Steve Pugh <steve (AT) pugh (DOT) net> <http://steve.pugh.net/>


Reply With Quote
  #3  
Old   
vKp
 
Posts: n/a

Default Re: 'Define' functionality in CSS? - 08-14-2003 , 06:03 PM



Jonathan Brady wrote:

Quote:
I couldn't find this anywhere so I'm not sure that it exists.

In most programming languages, one can define a value and then uses that
value by referencing the name in all of the source, and if that value
needs to be changed, then it's a simple matter of changing the
definition, and the change will be reflected of course throughout the
whole thing.

[SNIP]

Is there something like that in CSS and I missed it somehow, or is such
functionality non-existant in CSS?

No such functionality. Run your CSS through a preprocessor (such as
PHP). That's exactly what most languages do with DEFINE statements -
preprocess them.



Reply With Quote
  #4  
Old   
Stan Brown
 
Posts: n/a

Default Re: 'Define' functionality in CSS? - 08-15-2003 , 10:41 AM



In article <0001HW.BB6152E0011C9260F0305600 (AT) enews (DOT) newsguy.com> in
comp.infosystems.www.authoring.stylesheets, Jonathan Brady
<jbrady (AT) removethisspamkiller (DOT) myfmail.com> wrote:
Quote:
In most programming languages, one can define a value and then uses that
value by referencing the name in all of the source, and if that value
needs to be changed, then it's a simple matter of changing the
definition, and the change will be reflected of course throughout the
whole thing.
If only there were a FAQ we could point people to. (*)

Brady's is a _very_ common request, but the answer is: not within
CSS. Use some sort of preprocessor -- you maintain files with
#define or the like, and the preprocessor outputs your actual CSS
files.

(*) I mean one that is actually maintained. :-(

--
Stan Brown, Oak Road Systems, Cortland County, New York, USA
http://OakRoadSystems.com/
HTML 4.01 spec: http://www.w3.org/TR/html401/
validator: http://validator.w3.org/
CSS 2 spec: http://www.w3.org/TR/REC-CSS2/
validator: http://jigsaw.w3.org/css-validator/


Reply With Quote
  #5  
Old   
Tim
 
Posts: n/a

Default Re: 'Define' functionality in CSS? - 08-15-2003 , 01:55 PM



On Thu, 14 Aug 2003 14:53:20 -0400,
Jonathan Brady <jbrady (AT) removethisspamkiller (DOT) myfmail.com> wrote:

Quote:
I couldn't find this anywhere so I'm not sure that it exists.

In most programming languages, one can define a value and then uses that
value by referencing the name in all of the source, and if that value
needs to be changed, then it's a simple matter of changing the
definition, and the change will be reflected of course throughout the
whole thing.

This could come in very handy in creating similar stylesheets to create
various schemes.
For common variables across different stylesheets, having something
generate your CSS for you would be the best solution.

For common things within a single stylesheet, you can write your
stylesheets in a different manner.

e.g. Put common stuff at the start:

p, td, div {color:red; background-color:white;}
h1, h2, th {color:blue: background-color:yellow;}

Then continue to define the individual stuff, later:

p {margin:auto; max-width: 55em;}
div {border: thin solid black;}
th {padding: 0.3em;}

--
My "from" address is totally fake. The reply-to address is real, but
may be only temporary. Reply to usenet postings in the same place as
you read the message you're replying to.


Reply With Quote
  #6  
Old   
Jonathan Brady
 
Posts: n/a

Default Re: 'Define' functionality in CSS? - 08-16-2003 , 02:58 PM



On Fri, 15 Aug 2003 14:07:06 -0400, Tim wrote
(in message <ta7qjv80rs5pcfn5dua7u59vefpimpvcnv (AT) 4ax (DOT) com>):

Quote:
For common variables across different stylesheets, having something
generate your CSS for you would be the best solution.

For common things within a single stylesheet, you can write your
stylesheets in a different manner.

e.g. Put common stuff at the start:

p, td, div {color:red; background-color:white;}
h1, h2, th {color:blue: background-color:yellow;}

Then continue to define the individual stuff, later:

p {margin:auto; max-width: 55em;}
div {border: thin solid black;}
th {padding: 0.3em;}
I've been doing this so far. But it's a kludge of a solution.

I was simply looking to see if I overlooked the functionality before
building my own solution.

--
J Brady



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.