HighDots Forums  

Solution! Alternating table row colors (fun with CSS Expressions)

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


Discuss Solution! Alternating table row colors (fun with CSS Expressions) in the Cascading Style Sheets forum.



Reply
 
Thread Tools Display Modes
  #21  
Old   
Salagir
 
Posts: n/a

Default Re: Solution! Alternating table row colors (fun with CSS Expressions) - 09-08-2004 , 02:01 AM






On Tue, 7 Sep 2004 22:31:52 -0500, in comp.infosystems.www.authoring.stylesheets,
Matt Kruse wrote:
Quote:
There's nothing in there that says one can only discuss CSS solutions which
work on as wide an assortment of browsers as possible!
THe key is not "widest assortment of browsers as possible" but "www
conforming browsers".
IE isn't. That's all.

And that's why the Subject should not have been "Solution!..."
but more something like "IE hack for alternating table row colors (fun
with JS in CSS)"
You would certainly be less flamed.


And for the "unthinking masses" in another post, we're not saying we're
more clever than you are, just that you're unthinking: you don't choose
your browser, and just take the first thing that Windows will open for
you.

--
++++++++ Zelda, Dragon Ball, Mana and my (art)work at www.salagir.com ++++++++


Reply With Quote
  #22  
Old   
Berislav Lopac
 
Posts: n/a

Default Re: Solution! Alternating table row colors (fun with CSS Expressions) - 09-08-2004 , 02:51 AM






Matt Kruse wrote:
Quote:
Toby Inkster wrote:
Correct me if I'm wrong (and I may well be), but don't MSIE's
expressions require JScript to be enabled? If so, what's the
advantage of using them over proper scripting?

They do require scripting to be on. I think they are much easier to
implement because with a scripting solution you need to either fire
the action onLoad of the document, or put the script at the bottom of
the document to run after the main document loads. That's more of a
hassle than simply including a css file, IMO.
Or you can use window.onLoad in the script file itself, so it is no more of
a hassle than simply including a js file.

--
If the Internet is a Marx Brothers movie, and Web, e-mail, and IRC are
Groucho, Chico, and Harpo, then Usenet is Zeppo.




Reply With Quote
  #23  
Old   
Chris Sharman
 
Posts: n/a

Default Re: Solution! Alternating table row colors (fun with CSS Expressions) - 09-08-2004 , 02:58 AM



Matt Kruse wrote:
Quote:
http://www.mattkruse.com/temp/css_expressions.html

One of the standard CSS questions is "how can I shade every other table row
a different color with CSS?"

The answers are usually 1) you can't (yet), 2) put a class on every other
tr, or 3) use javascript to do the styling for you.

Well, I've been playing the CSS expressions quite a bit lately and I've
found a much simpler solution which works in IE5.5+, using "expressions". If
you're creating a web app that uses exclusively IE, or if you want to add
this feature for the majority of site visitors (using IE), then you can use
the technique in the url above. At that url are some other fun things that
CSS expressions can do also.

I realize the CSS expressions are non-standard and not a solution which
everyone will find acceptable. But for those that can accept the limited
browser support (IE only) then they are quite powerful and convenient. On
projects where IE is the only browser being used to access the web app, this
is going to be a great solution for me, I think. And in the future, as CSS
evolves and browsers support more advanced selectors, the CSS file can be
changed simply without needing to change anything in the content.

Thoughts?
Great stuff. Can't believe the amount of negative responses you've got.
I use moz myself, and hope for the day when I can develop to standards,
but in the real world I see ie6 as the majority, and ie5 second,
together somewhere between 90 & 97% on the site stats I see, and has
been increasing for some time, so it's more hope than anticipation.

What I find 'unacceptable' are 'standard' solutions which don't work for
ie5+ - without an accompanying 'ie hack' they are pretty useless
(rightly or wrongly), except possibly for websites willing to write off
a large proportion of visitors.

Your solution:
degrades gracefully
is in the CSS (where it belongs)
will one day be useful in conjunction with css3 (as an ie hack).

We can loathe ie, but we can't realistically ignore it, and anything
which helps improve the browsing experience for ie users on our pages,
without degrading it for others, is to be applauded. Any web author who
thinks otherwise is obviously authoring primarily for web evangelism of
some kind, rather than any other cause, commercial or charitable.

Ducking now ...
Chris


Reply With Quote
  #24  
Old   
Jan Roland Eriksson
 
Posts: n/a

Default Re: Solution! Alternating table row colors (fun with CSS Expressions) - 09-08-2004 , 03:28 AM



On Tue, 7 Sep 2004 22:31:52 -0500, "Matt Kruse"
<newsgroups (AT) mattkruse (DOT) com> wrote:

Quote:
Neal wrote:
This ng, which is centered on WWW authoring, deals with solutions
which work on as wide an assortment of browsers as possible.

You seem to be making a false assumption.
This newsgroup is for discussion of CSS. That's it.
From the FAQ:

Q: What kinds of posts are acceptable in this news group ?
A: Topics for this news group include:
* How to achieve a particular effect with style sheets,
* The relative advantages of different style sheet languages,
* Specifications versus implementations,
* Bugs and limitations in implementations, and
* Questions on XSL related subjects.

There's nothing in there that says one can only discuss CSS solutions which
work on as wide an assortment of browsers as possible!
Sure, but "CSS expressions" is not a part of any recognized style sheet
language. IMMIC these so called "expressions" surfaced as a result of a
5 year old dead end work on what was called BECSS (Behavioral Extensions
to CSS), where only MS actually did try to implement it (partially).

<http://www.w3.org/TR/1999/WD-becss-19990804>

If you'd like to discuss BECSS in IE5+ browsers with reference to the
m-FAQ of this NG it would fit better under the A-line "Bugs and
limitations in implementations" than to try to promote it as a "feature"
for some.

Quote:
No it's not. There are solutions here which only work in Mozilla and Opera,
because IE doesn't support as much CSS. Does that mean these posts are
off-topic?
No, all along the line that CSS is optional and not supporting some
aspects of it is in fact according to specs.

[...]

Quote:
Just because a solution doesn't work on _all_ browsers in a www
context does not mean it's worthless in a www context.
What you may want to worry about more is whether MS will offer continued
support for your promoted part of BECSS in a possible future IE version.

If you ask me I think its just plain stupid to suggest a presentation
that requires both a non standard CSS extension _and_ JScript in order
to "work".

In the meantime, while waiting for support of odd and even element
selectors, there are other fully supported ways to do what you want.

--
Rex




Reply With Quote
  #25  
Old   
Chris Morris
 
Posts: n/a

Default Re: Solution! Alternating table row colors (fun with CSS Expressions) - 09-08-2004 , 04:58 AM



"Alan J. Flavell" <flavell (AT) ph (DOT) gla.ac.uk> writes:
Quote:
Table -columns- in alternating colours are quite awkward, though.
Well, of course it's easy, but it seems so wasteful setting classes on
every damned table cell, that one feels the need to find a more
appealing solution.
Doesn't work in IE, naturally, but for tables with column headers:
....
<tr><th id="th1">Col Header 1</th><th id="th2">Col Header 2<th>...
....
<tr><td headers="th1">...

td[headers~=th1],td[headers~=th3],td[headers~=th5] {
...
}

Or alternatively
td, td + td + td, ...
and
td + td, ...

Again doesn't work in IE.

So possibly that plus the IE expression thing, if the alternating
colours are important [1].

[1] With the usual caveat that they can't be that important or they'd
be expressed by <strong> or <em> on the cell contents rather than CSS
on the cell.

--
Chris









Reply With Quote
  #26  
Old   
Alan J. Flavell
 
Posts: n/a

Default Re: Solution! Alternating table row colors (fun with CSS Expressions) - 09-08-2004 , 06:46 AM



On Tue, 7 Sep 2004, Matt Kruse wrote:

Quote:
I'm saying other browsers need to catch up, because at least IE
provides an easy way to do it NOW
http://www.us-cert.gov/cas/tips/ST04-012.html

Before clicking on a link to a web site that you are not familiar
with or do not trust, take the precaution of disabling active
content.

MS themselves have also intermittently given similar advice.

In a WWW context (which is what this group is about), it's probably
wise to treat all web sites as untrusted unless/until one has good
reason for doing otherwise.

On the other hand, all CSS is optional; so your IE-specific "solution"
is technically "working" even when it's doing nothing, I suppose.


Reply With Quote
  #27  
Old   
Alan J. Flavell
 
Posts: n/a

Default Re: Solution! Alternating table row colors (fun with CSS Expressions) - 09-08-2004 , 06:55 AM



On Tue, 7 Sep 2004, Matt Kruse wrote:

Quote:
This newsgroup is for discussion of CSS. That's it.
Actually no. Other stylsheet languages would be on topic here, if
anyone was interested in discussing them. But don't you see the
"WWW" in the name hierarchy? That's there for a reason.

Quote:
Wrong again. Just because a solution doesn't work on _all_ browsers
in a www context does not mean it's worthless in a www context.
It doesn't mean that it's worthless, right. But is it a "solution",
in a WWW context? To my way of thinking, it's no more a "solution"
than to propose making the materials available only in PowerPoint
format, rather than HTML+CSS. Which some folks certainly feel is the
right thing to do (I don't agree with them, just in case there's any
doubt).


Reply With Quote
  #28  
Old   
Matt Kruse
 
Posts: n/a

Default Re: Solution! Alternating table row colors (fun with CSS Expressions) - 09-08-2004 , 07:48 AM



Salagir wrote:
Quote:
And for the "unthinking masses" in another post, we're not saying
we're more clever than you are, just that you're unthinking: you don't
choose your browser, and just take the first thing that Windows will open
for
you.
Typical elitist bullshit that so many of you parrots like to espouse.

FYI, I have about 20 browsers installed on my computer, including mozilla,
opera, netscape, and IE. I've used about every browser imaginable, since the
first release of mosaic. On several occassions I've moved to other browsers
as my 'primary' browser, only to move back to IE. I simply prefer it. To
imply that I or anyone else who chooses to use IE is doing so because we are
unthinking makes you look pretty stupid. IMO.

--
Matt Kruse
http://www.JavascriptToolbox.com




Reply With Quote
  #29  
Old   
C A Upsdell
 
Posts: n/a

Default Re: Solution! Alternating table row colors (fun with CSS Expressions) - 09-08-2004 , 09:07 AM



"Chris Sharman" <chris.sharman (AT) sorry (DOT) nospam> wrote

Quote:
Matt Kruse wrote:
We can loathe ie, but we can't realistically ignore it, and anything which
helps improve the browsing experience for ie users on our pages, without
degrading it for others, is to be applauded. Any web author who thinks
otherwise is obviously authoring primarily for web evangelism of some
kind, rather than any other cause, commercial or charitable.
But what the OP wants to do can be done using standard CSS that works on all
browsers other than antiques. The 'solution' he came up with is for IE5.5+
only. I don't believe that criticising an IE-only solution when a simple
cross-browser solution exists has anything to do with 'web evangelism'.






Reply With Quote
  #30  
Old   
Matt Kruse
 
Posts: n/a

Default Re: Solution! Alternating table row colors (fun with CSS Expressions) - 09-08-2004 , 09:28 AM



C A Upsdell wrote:
Quote:
But what the OP wants to do can be done using standard CSS that works
on all browsers other than antiques. The 'solution' he came up with
is for IE5.5+ only. I don't believe that criticising an IE-only
solution when a simple cross-browser solution exists has anything to
do with 'web evangelism'.
The two solutions are different approaches to solving the same problem, and
each has their own merits and drawbacks.

The 'standard' solution is to include a class="odd" or whatever on every
other row to highlight the row.
Pros:
1) Works across browsers using standard css
2) Easy to understand
Cons:
1) Requires server-side effort to insert classes
2) Row classes must be reassigned if the rows are sorted, inserted, or
deleted. It's very static.

The solution I posted:
Pros:
1) Uses only a single rule, and no class properties in rows. Row shading
can be added to a site by adding a single css rule which will work for all
tables on the site.
2) Continues to shade correctly even if you sort, insert, or delete rows
3) Rule can easily be swapped out later for a css3-style odd/even
selector when supported by newer browsers
Cons:
1) Only works in IE, with js enabled

Obviously, any intelligent designer needs to consider he pros and cons of
available solutions when deciding how to implement a feature. If you're
designing a public site and it's vital that as many visitors as possible see
the row shading, then the cross-browser solution is the logical choice. If
you're creating an internal site that is only accessed by IE, or if your
visitors are 90% IE and you don't care if 10% of visitors don't see the row
shading, then the solution I posted saves a lot of effort and provides more
benefits. It's the logical choice, IMO.

Look, people, it's just an option. It's a solution to a problem. It works,
in a known environment, which is all you can ask of _any_ solution. Whether
or not it's valuable to you is a personal decision based on your
requirements.

But it's quite ridiculous to proclaim something to be useless simply because
_you're_ requirements don't make it a viable solution for _you_.

--
Matt Kruse
http://www.JavascriptToolbox.com




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.