Re: table columns and rows in css?

Discussion in 'HTML' started by Jukka K. Korpela, Aug 31, 2003.

  1. "James Yu" <> wrote:

    > Is there a way to specify the attributes of a column in using css?


    This is a tricky issue. The short answer is "mostly not".

    > As an example.. I want something like..
    >
    > mytableclass#col1 {
    > width: bla
    > ...
    > }


    Width is a special case. It would often be sufficient to set the widths
    for the cells in the first row only. You could even use the width="..."
    attribute in HTML, but this has serious limitations (the width must then
    be in pixels or percentages, which is rather inflexible).

    > Or do I have to go through the
    > whole table and ad the id "col1" in every td...?


    Why would you use id attributes? Remember that id values must be unique,
    i.e. two elements must not have the same id value.

    The safest way to ensure that you can style a column is to specify the
    same class attribute for each cell in the column. Unfortunate, but not
    really much of a problem in practice if you use a good editor.

    Regarding rows (though they perhaps don't interest you since you
    mentioned them in the Subject line only), the situation is much simpler.
    You can assign a class to a <tr> element, say <tr class="special">, and
    use a contextual selector as in
    tr.special th, tr.special td { background: yellow; color: black; }

    --
    Yucca, http://www.cs.tut.fi/~jkorpela/
    Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html
    Jukka K. Korpela, Aug 31, 2003
    #1
    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. Subba Rao via DotNetMonster.com

    script for moving rows up and down and traverse thru rows of HTML table

    Subba Rao via DotNetMonster.com, Mar 19, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    8,196
    Subba Rao via DotNetMonster.com
    Mar 19, 2005
  2. helpful sql
    Replies:
    0
    Views:
    792
    helpful sql
    May 19, 2005
  3. Rio
    Replies:
    4
    Views:
    1,172
  4. Replies:
    1
    Views:
    100
  5. Replies:
    1
    Views:
    97
Loading...

Share This Page