Results 1 to 3 of 3

Thread: Help with column justification PLEASE!

  1. #1
    Join Date
    Sep 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Help with column justification PLEASE!

    I have a problem with table columns. Columns 1 & 2 are left
    justified, and column 3 is right justified. Currently, the code is:

    <colgroup style="text-align: left"></colgroup>
    <colgroup style="text-align: left"></colgroup>
    <colgroup style="text-align: right"></colgroup>

    <tr>
    <td>this column is left</td>
    <td>this column is left</td>
    <td>this column is right</td>
    </tr>

    It works in IE, but Firefox does not like that, and all columns show
    as left justified.

    I know I can use <td style="text-align: right"> but the table is
    over 500 rows, and I don't want to make 500 changes.

    Can I right-justify just the third column in my .css file? If so,
    how?

  2. #2
    Join Date
    Jan 2006
    Location
    Ft. Smith, AR
    Posts
    795
    Thanks
    57
    Thanked 129 Times in 116 Posts

    Default

    well, depending on what the REST of your code looks like... you can use nested styling if you don't want to go through and change each individual <td> to add a class to it or use inline styling.

    It would look something like this..

    Code:
    <style type="text/css">
    tr td td td {
    text-align:right;
    }
    --------------------------------------------------
    Reviews, Interviews, Tutorials, and STUFF
    --------------------------------------------------
    Home of the SexyBookmarks WordPress plugin

  3. The Following User Says Thank You to TheJoshMan For This Useful Post:

    Maynard (10-12-2008)

  4. #3
    Join Date
    Mar 2007
    Location
    Currently: New York/Philadelphia
    Posts
    2,735
    Thanks
    3
    Thanked 519 Times in 507 Posts

    Default

    @mogomuta...
    The trouble here is that text-align for use on <colgroups> or <col> isn't part of any W3C standard. So, the standard-compliant browsers have neglected to implement in. IE, because it can't do EVERYTHING wrong, is kind of ahead of the curve in adding it.

    But, since all of the modern browsers (to my knowledge, anyway)in their most recent releases now have support for :first-child and sibling selectors, you can indeed do it via CSS.

    Keep the inline styles that you have already for IE's sake. For everything else, use the following:
    Code:
    <style type="text/css">
    	td:first-child + td + td {
    		text-align:right;
    	}
    </style>
    @Josh...
    That would work if there were 2 nested tables within each cell. That's not the case here.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •