HighDots Forums  

style based on tag content

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


Discuss style based on tag content in the Cascading Style Sheets forum.



Reply
 
Thread Tools Display Modes
  #11  
Old   
jpolaski@rgs.uci.edu
 
Posts: n/a

Default Re: style based on tag content - 05-03-2006 , 01:04 PM






That's the best solution so far. I'll have to come up with a set of
behaviors for our site.

Thank you!


Reply With Quote
  #12  
Old   
Harlan Messinger
 
Posts: n/a

Default Re: style based on tag content - 05-03-2006 , 01:18 PM






Martin Eyles wrote:
Quote:
The closest I can think of is attribute selectors.

http://www.w3.org/TR/CSS21/selector....bute-selectors

[att=val]
Match when the element's "att" attribute value is exactly "val".

However I don't think you can have content as the att.
Just to confirm: you can't. An element's content isn't an attribute.


Reply With Quote
  #13  
Old   
VK
 
Posts: n/a

Default Re: style based on tag content - 05-03-2006 , 01:25 PM




jpolaski (AT) rgs (DOT) uci.edu wrote:
Quote:
That's the best solution so far. I'll have to come up with a set of
behaviors for our site.

Thank you!
You are welcome. I have some set of copyright free twinpairs (XBL/HTC)
for some most common task. Ask if you need.



Reply With Quote
  #14  
Old   
Harlan Messinger
 
Posts: n/a

Default Re: style based on tag content - 05-03-2006 , 01:45 PM



VK wrote:
Quote:
jpolaski (AT) rgs (DOT) uci.edu wrote:
I'd like to change the color of text in a table data field based on the
content...

For example, I'd like all <td>pos</td> to show the "pos" in red. All
td>pending</td> should show as the normal black. I don't really want
to have to add a class or a style, but that's how I've been doing it so
far...

I seem to remember that this is possible, I just can't remember the
syntax right now and I'm not having any luck with google...

Thanks in advance,

Use behaviors
IE 5.5 or higher
Firefox 1.0 or higher
Camino 1.0 or higher
any other modern Gecko based browser
Netscape 8.0 or higher
[demo snipped]

Seems like an awful lot of work to use a behavior for this. Wouldn't it
be easier to take the working part of it and stick it in a script?

function adjustTable(table)
{
var tds = table.getElementsByTagName("td");
var iTD;
for (iTD = 0; iTD < tds.length; iTD++)
{
switch ...

}
}

[in onload handler]
adjustTable(document.getElementById("myTable"));

If the scope should be restricted to particular columns, then you
approach of going methodically through the TBODY and then TRs makes sense.


Reply With Quote
  #15  
Old   
VK
 
Posts: n/a

Default Re: style based on tag content - 05-03-2006 , 02:51 PM




Harlan Messinger wrote:
Quote:
Use behaviors
IE 5.5 or higher
Firefox 1.0 or higher
Camino 1.0 or higher
any other modern Gecko based browser
Netscape 8.0 or higher

[demo snipped]

Seems like an awful lot of work to use a behavior for this. Wouldn't it
be easier to take the working part of it and stick it in a script?

function adjustTable(table)
{
var tds = table.getElementsByTagName("td");
var iTD;
for (iTD = 0; iTD < tds.length; iTD++)
{
switch ...

}
}

In this particular case it is replaceable by <script>, because we do
not have to augment elements by new properties/methods, do not insert
anonymous content, do not require refactored events for bounds elements
etc.

In the "Sticky Notes" sample
<http://developer.mozilla.org/en/docs/XBL:XBL_1.0_Reference#Example_-_Sticky_Notes>

we have a HTML 4.01 Strict valid document with notes decorated with SVG
(Gecko) / VML (IE) graphics being part of the document tree (and more).

Also "a lot of work" for who? ;-) Any solution requires some initial
work, sometimes a lot of work - all eventually expressed in one line
<script src="myscript.js"></script>.
The question is how easy is to raise the solution over and over again
without adjusting it for new context every time. In this aspect to have
everything in one .css sheet with two lines added:
table {
....
-moz-binding: url(zebra.xml#default);
behavior: url(zebra.htc);
}
doesn't need a lot of work.


Quote:
If the scope should be restricted to particular columns, then you
approach of going methodically through the TBODY and then TRs makes sense.
Well... Only to you alone: a dark secret of XBL :-) In the current
Gecko implementation in tables one can attach bindings only to the
table element itself, not to tr or td (bug 83830). IE behavior doesn't
have this limitation. Without this bug I would attach bindings right to
rows which has much more sense - and would let me stay out of any
coding at all.



Reply With Quote
  #16  
Old   
jpolaski@rgs.uci.edu
 
Posts: n/a

Default Re: style based on tag content - 05-03-2006 , 05:42 PM



No, it doesn't work. Yes, that's what I was originally thinking of.

As things stand now, there is no easy solution.


Reply With Quote
  #17  
Old   
Tony
 
Posts: n/a

Default Re: style based on tag content - 05-03-2006 , 06:15 PM



Quote:
Running Apple programs on a PC doesn't work, even if you were
thinkig of using an emulator

jpolaski (AT) rgs (DOT) uci.edu wrote:
No, it doesn't work. Yes, that's what I was originally thinking of.

As things stand now, there is no easy solution.


Is your car running? Or maybe you could take public transportation?
Otherwise, how are you going to get to work?

jpolaski (AT) rgs (DOT) uci.edu wrote:
No, it doesn't work. Yes, that's what I was originally thinking of.

As things stand now, there is no easy solution.


Such a radical change is likely to cause problems. Maybe we should
consider a more measured approach.

jpolaski (AT) rgs (DOT) uci.edu wrote:
No, it doesn't work. Yes, that's what I was originally thinking of.

As things stand now, there is no easy solution.


Sorry - I'm trying...


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.