css selecter question

Discussion in 'HTML' started by Disco Octopus, Nov 14, 2003.

  1. 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.
    Disco Octopus, Nov 14, 2003
    #1
    1. Advertising

  2. 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
    Toby A Inkster, Nov 14, 2003
    #2
    1. Advertising

  3. "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
    Jukka K. Korpela, Nov 14, 2003
    #3
  4. 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
    Matthias Gutfeldt, Nov 14, 2003
    #4
  5. Matthias Gutfeldt <> 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
    Jukka K. Korpela, Nov 15, 2003
    #5
  6. Jukka K. Korpela wrote:
    > Matthias Gutfeldt <> 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 {...}
    Disco Octopus, Nov 16, 2003
    #6
  7. 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
    Toby A Inkster, Nov 16, 2003
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Eric
    Replies:
    4
    Views:
    712
    clintonG
    Dec 24, 2004
  2. tom watson

    print.css and screen.css

    tom watson, Sep 9, 2003, in forum: HTML
    Replies:
    1
    Views:
    464
    Jukka K. Korpela
    Sep 9, 2003
  3. Replies:
    6
    Views:
    549
    Jonathan N. Little
    Mar 18, 2006
  4. AF
    Replies:
    17
    Views:
    599
    Nije Nego
    Aug 9, 2006
  5. richard
    Replies:
    12
    Views:
    753
    dorayme
    Mar 9, 2010
Loading...

Share This Page