473,394 Members | 1,866 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

'Define' functionality in CSS?

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

Jul 20 '05 #1
5 8835
Jonathan Brady <jb****@removethisspamkiller.myfmail.com> wrote:
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...
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 <st***@pugh.net> <http://steve.pugh.net/>
Jul 20 '05 #2
vKp
Jonathan Brady wrote:
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.

Jul 20 '05 #3
In article <00*****************************@enews.newsguy.com > in
comp.infosystems.www.authoring.stylesheets, Jonathan Brady
<jb****@removethisspamkiller.myfmail.com> wrote:
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/
Jul 20 '05 #4
Tim
On Thu, 14 Aug 2003 14:53:20 -0400,
Jonathan Brady <jb****@removethisspamkiller.myfmail.com> wrote:
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.
Jul 20 '05 #5
On Fri, 15 Aug 2003 14:07:06 -0400, Tim wrote
(in message <ta********************************@4ax.com>):
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

Jul 20 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: MrKrinkle | last post by:
I want to universally define the __call() method, so that every class in my application does the same thing if a non-existant function is called. In actionscript I could do this by adding the...
31
by: bilbothebagginsbab5 AT freenet DOT de | last post by:
Hello, hello. So. I've read what I could find on google(groups) for this, also the faq of comp.lang.c. But still I do not understand why there is not standard method to "(...) query the...
6
by: David Young | last post by:
Hello all, I'm quite new to C# (< 6 months) but really love it and is my language of choice ..... but I have one question I've not been able to find out ..... In C++ a #define label in one...
5
by: Rob | last post by:
In many articles related to VB.net the word "class" is used... How many meanings are there to this word ? "possible to derived a class from another" "forms are full-fledged classes" "base...
10
by: O Plameras | last post by:
Are there differences in terms of functionality of, #define and typedef ? By the above I mean any instance when the outcome obtained by running two versions (1) and (2) below of C codes...
2
by: FBM | last post by:
Hi, I am preparing project for submission and i'd like to allow the print out of debug messages. I know that with something like #define DEBUG #ifdef DEBUG print(X); #endif
69
by: RC | last post by:
I know how to do this in JavaScript by window.open("newFile.html", "newTarget", "scrollbars=no,resizable=0,width=200,height=200"); The browser will open a new window size 200x200, not allow...
1
by: kdsutaia | last post by:
Hi! Everyone, In my project i need to enter query and program should go to google and get googled output source file. can anyone give some idea how do i implement this ? i know i can use...
0
by: kdsutaia | last post by:
Hi! Everyone, In my project i need to enter query on commond line and program should go to google and get googled output source file. can anyone give some idea how do i implement this ? i know i...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.