Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > css selecter question

Reply
Thread Tools

css selecter question

 
 
Disco Octopus
Guest
Posts: n/a
 
      11-14-2003
Hi,
I was told that doing somehing like this is not valid CSS. I would like to
get a second opinion please....

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>my title</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<style type="text/css">
<!--
.dog td.toprow {color:red;background-color:blue;}
-->
</style>
</head>
<body>
<table class="dog">
<tr>
<th>header row data</th>
<th>header row data</th>
</tr>
<tr>
<td class="toprow">top row data</td>
<td class="toprow">top row data</td>
</tr>
<tr>
<td>not</td>
<td>not</td>
</tr>
</table>
</body>
</html>


Please note the style block, and please tell me if there is something not
perfect about the construction of the selector ".dog td.toprow { ... }"

If this is invalid, can you please give me a link to the W3C page that
suggests that this is invalid.

thanks very much.



 
Reply With Quote
 
 
 
 
Toby A Inkster
Guest
Posts: n/a
 
      11-14-2003
Disco Octopus wrote:

> I was told that doing somehing like this is not valid CSS. I would like to
> get a second opinion please....


Looks fine to me. There is no need for the "<!--" and "-->" comments in
the CSS. It only effects some obscure beta of Netscape 3 Gold.

--
Toby A Inkster BSc (Hons) ARCS
Contact Me - http://www.goddamn.co.uk/tobyink/?page=132

 
Reply With Quote
 
 
 
 
Jukka K. Korpela
Guest
Posts: n/a
 
      11-14-2003
"Disco Octopus" <> wrote:

> I was told that doing somehing like this is not valid CSS. I would like
> to get a second opinion please....


OK, here's one: it is valid CSS. (Note that I'm giving you an opinion, not
saying that it's my opinion.)

Are there some other opinions? Well, could we say that it is both valid and
not valid? Or that it is neither? (Cf. to "this is sparkling CSS".)

--
Yucca, http://www.cs.tut.fi/~jkorpela/
Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html


 
Reply With Quote
 
Matthias Gutfeldt
Guest
Posts: n/a
 
      11-14-2003
Jukka K. Korpela wrote:
> "Disco Octopus" <> wrote:
>
>
>>I was told that doing somehing like this is not valid CSS. I would like
>>to get a second opinion please....

>
>
> OK, here's one: it is valid CSS. (Note that I'm giving you an opinion, not
> saying that it's my opinion.)
>
> Are there some other opinions? Well, could we say that it is both valid and
> not valid? Or that it is neither? (Cf. to "this is sparkling CSS".)


LOL!

Yes, there was a different opinion. Someone in alt.php claimed it's not
valid. The guy obviously didn't understand CSS.


Matthias

 
Reply With Quote
 
Jukka K. Korpela
Guest
Posts: n/a
 
      11-15-2003
Matthias Gutfeldt <say-no-to-> wrote:

> Someone in alt.php claimed it's not
> valid. The guy obviously didn't understand CSS.


Well, who _does_ understand CSS? We just have different holes in our
understanding. And this includes people who sort-of have defined and are
redefining CSS.

Anyway, the CSS rule
.dog td.toprow {color:red;background-color:blue;}
complies with CSS specifications (both CSS 1 and CSS 2) under any
interpretation. Some people say that this means it's "valid". Well, that's a
bit confusing, but not that it would remain exactly as "valid" if you
replaced the color name blue by the color name red (making text color and
background color the same).

It's not god CSS practice, though. The colors used (the "pure" colors) are
usually unsuitable for use on the Web, and that particular color combination
is not very good. Moreover, it would be better to set background, not just
background-color, since now any other style sheet that participates in the
cascade may freely set a background image, e.g. a nice Christmas-style
background which has strong red colors and little else.

As a practical consideration, it would be more natural to assign a class to
a <tr> element than to each <td> inside it separately. The latter approach
might escape some browser bugs, though.

--
Yucca, http://www.cs.tut.fi/~jkorpela/
Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html


 
Reply With Quote
 
Disco Octopus
Guest
Posts: n/a
 
      11-16-2003
Jukka K. Korpela wrote:
> Matthias Gutfeldt <say-no-to-> wrote:
>
>> Someone in alt.php claimed it's not
>> valid. The guy obviously didn't understand CSS.

>
> Well, who _does_ understand CSS? We just have different holes in our
> understanding. And this includes people who sort-of have defined and
> are redefining CSS.
>
> Anyway, the CSS rule
> .dog td.toprow {color:red;background-color:blue;}
> complies with CSS specifications (both CSS 1 and CSS 2) under any

My confusion is now that he has said the actual selector is not valid. (IE
the first "." (dot) in the selector _._dog td.toprow {...}


 
Reply With Quote
 
Toby A Inkster
Guest
Posts: n/a
 
      11-16-2003
Disco Octopus wrote:

> My confusion is now that he has said the actual selector is not valid. (IE
> the first "." (dot) in the selector _._dog td.toprow {...}


Well, he is wrong.

".dog" is a valid shorthand for "*.dog" which will match any of the
following elements, amongst others:

<p class="dog" />
<div class="dog" />
<em class="big dog" />
<a class="hairy dog" />
<span class="hot dog with ketchup" />

--
Toby A Inkster BSc (Hons) ARCS
Contact Me - http://www.goddamn.co.uk/tobyink/?page=132

 
Reply With Quote
 
 
 
Reply

Thread Tools

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: correction: A question about css (was: A question about css) richard HTML 12 03-09-2010 08:52 PM
Is this the newsgroup for CSS help? CSS Question Included AF HTML 17 08-09-2006 06:57 PM
CSS question - can I make CSS Cascade sideways? Bill_W_Stephens@yahoo.com HTML 6 03-18-2006 06:02 PM
CSS Layout question - how to duplicate a table layout with CSS Eric ASP .Net 4 12-24-2004 04:54 PM
print.css and screen.css tom watson HTML 1 09-09-2003 02:48 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57