473,399 Members | 3,302 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,399 software developers and data experts.

duplicate in CSS

Is there no way to refer to an existing rule to set a value for a new
rule short of generating a style sheet server side?

For example:

div.a {color: blue;}
div.b {color: div.a.color}

Without this type of mechanism you end up duplicating values. I
usually try to avoid duplicating data because it creates maintenance
overhead. What's the deal? This seems so obvious I don't understand
why it can't be done. Or can it? Or how is this handled?

TIA
Jul 20 '05 #1
8 4578
"David Beardsley" <db**********@hotmail.com> wrote in message
news:a2**************************@posting.google.c om...
Is there no way to refer to an existing rule to set a value for a new
rule short of generating a style sheet server side? ...
Not that I know of, though someone may
jump in and prove me wrong.
Without this type of mechanism you end up duplicating values. I
usually try to avoid duplicating data because it creates maintenance
overhead.


You are duplicating data (in CSS) but not
values (in source), or at least, you do not
have to.

e.g. java pseudocode
Color NAV_BG = new Color(#0000ff);
.....
div.a {color: <%= NAV_BG %>;}
div.b {color: <%= NAV_BG %>;}

Your maintenance for updating the color is
limited to changing a single value..

--
Andrew Thompson
* http://www.PhySci.org/ PhySci software suite
* http://www.1point1C.org/ 1.1C - Superluminal!
* http://www.AThompson.info/andrew/ personal site
Jul 20 '05 #2
David Beardsley <db**********@hotmail.com> wrote:
Is there no way to refer to an existing rule to set a value for a new
rule short of generating a style sheet server side?

For example:

div.a {color: blue;}
div.b {color: div.a.color}

Without this type of mechanism you end up duplicating values. I
usually try to avoid duplicating data because it creates maintenance
overhead. What's the deal? This seems so obvious I don't understand
why it can't be done. Or can it? Or how is this handled?


There are a couple of approaches. I use a preprocessor that generates the
final style sheet, but it seems that you're trying to avoid anything like
that. The "CSS alone" solution is to do something like this:

div.a, div.b {color: blue;}
--
Darin McGrew, da***@TheRallyeClub.org, http://www.TheRallyeClub.org/
A gimmick car rallye is not a race, but a fun puzzle testing your
ability to follow instructions. Upcoming gimmick car rallye in
Silicon Valley: Toy Rallye '03 (Sunday, December 7)
Jul 20 '05 #3
in post <news:a2**************************@posting.google. com>
David Beardsley said:
Is there no way to refer to an existing rule to set a value for a new
rule short of generating a style sheet server side?

For example:

div.a {color: blue;}
div.b {color: div.a.color}


..blah{..common properties..}
..color1{color:red;}
..color2{color:blue;}

class="blah color1"
class="blah color2"

--
brucie
10/December/2003 10:24:34 am kilo
Jul 20 '05 #4
"brucie" <br******@bruciesusenetshit.info> wrote in message
news:br*************@ID-117621.news.uni-berlin.de...
in post <news:a2**************************@posting.google. com>
David Beardsley said:
Is there no way to refer to an existing rule to set a value for a new
rule short of generating a style sheet server side?

For example:

div.a {color: blue;}
div.b {color: div.a.color}


.blah{..common properties..}
.color1{color:red;}
.color2{color:blue;}

class="blah color1"
class="blah color2"


To expand on Brucie's post...

Your HTML elements inherit the styles that you specify. If your HTML is
created in a nice hierarchy, then your styles should inherit automatically.
Suppose you have the following (I've changed class names to be something
meaningful):

<div class="cardetails">
<div class="make">Toyota</div>
<div class="model">Camry</div>
</div>

In this case, if you had styles like this:

..cardetails { color: blue; }

Then you don't need to specify the color for class "make" because it will be
inherited.

Now, if your HTML is less hierarchical and looks like this (nothing that
says these are children of a common class)

<div class="make">Toyota</div>
<div class="model">Camry</div>

rather than applying a color to make and a color to model, create a class
that encapsulates both objects:

..cardetails { color: blue; } /* common properties */

and add that class to your HTML elements:

<div class="cardetails make"> Toyota</div>
<div class="cardetails model">Camry</div>

This approach works, but is not as friendly to work with (IMO).
Regards,
Peter Foti


Jul 20 '05 #5
"Peter Foti" <pe****@systolicnetworks.com> wrote in message
news:vt************@corp.supernews.com...
"brucie" <br******@bruciesusenetshit.info> wrote in message
news:br*************@ID-117621.news.uni-berlin.de...
in post <news:a2**************************@posting.google. com>
..... <div class="cardetails make"> Toyota</div>
<div class="cardetails model">Camry</div>


I was testing some pages in IE6, Moz1.3 and NN4.78
the other day when I noticed that NN dropped every
style where I had specified two classes.

Your other encapsulation method, vis.
<div class="cardetails">
<div class="make">Toyota</div>
<div class="model">Camry</div>
</div>

Is an interesting possibility..

Is there any way to apply it to table cells,
or would you have to wrap the cell contents
in <span>/<div>s or similar?

--
Andrew Thompson
* http://www.PhySci.org/ PhySci software suite
* http://www.1point1C.org/ 1.1C - Superluminal!
* http://www.AThompson.info/andrew/ personal site
Jul 20 '05 #6
> > "brucie" <br******@bruciesusenetshit.info> wrote in message
news:br*************@ID-117621.news.uni-berlin.de...
in post <news:a2**************************@posting.google. com>


Hi brucie!

Apologies for my poor attribution trimming in the
last post, I forgot to trim your name when I was
only quoting Peter. I will try to be more careful.

--
Andrew Thompson
* http://www.PhySci.org/ PhySci software suite
* http://www.1point1C.org/ 1.1C - Superluminal!
* http://www.AThompson.info/andrew/ personal site
Jul 20 '05 #7
"Andrew Thompson" <an******@bigNOSPAMpond.com> wrote in message
news:nO*****************@news-server.bigpond.net.au...
"Peter Foti" <pe****@systolicnetworks.com> wrote in message
news:vt************@corp.supernews.com...
"brucie" <br******@bruciesusenetshit.info> wrote in message
news:br*************@ID-117621.news.uni-berlin.de...
in post <news:a2**************************@posting.google. com>

....
<div class="cardetails make"> Toyota</div>
<div class="cardetails model">Camry</div>


I was testing some pages in IE6, Moz1.3 and NN4.78
the other day when I noticed that NN dropped every
style where I had specified two classes.

Your other encapsulation method, vis.
<div class="cardetails">
<div class="make">Toyota</div>
<div class="model">Camry</div>
</div>

Is an interesting possibility..

Is there any way to apply it to table cells,
or would you have to wrap the cell contents
in <span>/<div>s or similar?


You could certainly apply this to table cells as well (though I'm not sure I
understand exactly what you mean). However, I find it generally more
reliable to apply style to the *contents* of table cells, vs. the actual
cells themselves. For example, you could do:
<table class="cardetails">
<tr>
<td class="make">Toyota</td>
<td class="model">Camry</td>
</tr>
</table>

Or you could do:
<table class="cardetails">
<tr>
<td><div class="make">Toyota</div></td>
<td><div class="model">Camry</div></td>
</tr>
</table>

etc., etc....

Is that what you meant?

Jul 20 '05 #8

"Peter Foti" <pe****@systolicnetworks.com> wrote in message
news:vt************@corp.supernews.com...
You could certainly apply this to table cells as well (though I'm not sure I understand exactly what you mean). However, I find it generally more
reliable to apply style to the *contents* of table cells, vs. the actual
cells themselves. For example, you could do:
<table class="cardetails">
<tr> .... Is that what you meant?


No, but what you wrote made me realise I
was going about it the dumb way. And better,
it clears up my thinking on how to apply styles
in that situation.

Thanks.

--
Andrew Thompson
* http://www.PhySci.org/ PhySci software suite
* http://www.1point1C.org/ 1.1C - Superluminal!
* http://www.AThompson.info/andrew/ personal site
Jul 20 '05 #9

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

Similar topics

3
by: Giloosh | last post by:
Hello, i need some help if possible... i have a payments table with over 500 records i want to run a query that searches through the table spotting out any duplicate ID#'s and Dates. So basically...
3
by: Mohammed Mazid | last post by:
Hi, Basically I have a problem with registering to my quiz system. I had borrowed some code from an existing program but I just do not know why it doesn't work. If (txtUsername = "" Or...
44
by: Xah Lee | last post by:
here's a large exercise that uses what we built before. suppose you have tens of thousands of files in various directories. Some of these files are identical, but you don't know which ones are...
1
by: Gary Lundquest | last post by:
It appears to me that MySQL version 4 returns an error messge when doing an Insert that results in duplicate entries. Version 3 did NOT return an error - it dropped the duplicate entries and ran...
9
by: vbportal | last post by:
Hi, I would like to add BitArrays to an ArrayList and then remove any duplicates - can someone please help me forward. I seem to have (at leaset ;-) )2 problems/lack of understanding (see test...
2
by: news | last post by:
I just upgraded to PHP 4.4.2 on my Slackware 10.2 system. And Apache/mySQL/PHP all work great through a browser. No errors. But when I try to run a PHP script through the command line, which I...
5
by: Manish | last post by:
The topic is related to MySQL database. Suppose a table "address" contains the following records ------------------------------------------------------- | name | address | phone |...
7
by: ucfcpegirl06 | last post by:
Hello, I have a dilemma. I am trying to flag duplicate messages received off of a com port. I have a software tool that is supposed to detect dup messages and flag and write the text "DUP" on...
4
by: FangQ | last post by:
hi I am very new to mysql. I have a question about using the "on duplicate update" clause with insert command. my table "data" has two columns, field1 and field2, where field1 is the index...
3
by: rajeshkrsingh | last post by:
Hi friends, Step1- create table duplicate ( intId int, varName varchar(50) ) insert into duplicate(intId,varName) values(1,'rajesh') insert into duplicate(intId,varName) values(2,'raj12')...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.