[HTML] / [CSS] multiple width's in one table

Discussion in 'Web Design & Coding' started by Glaanieboy, Jan 23, 2004.

  1. Glaanieboy

    Glaanieboy Moderator

    Messages:
    2,626
    Location:
    The Netherlands
    I am currently making a news page, for my Songviewer webpage. Each news item contains 3 parts, as you can see in this working example, the date/posted by, title and message body. I have created 4 example news items, which all are in one table. I have decided, to make them stand out better, that both the title and message body get a border and a background color (the colors on the working example are there only for the test, don't brag about it). All nice and well, but I want the width of the title bar to be smaller than the message width. With smaller I mean just as wide as the title-text.

    I can think of one option: Use multiple tables for one message, ie creating a table for the date/posted by, one table for the title and one for the message. The width for the title-table is calculated by a PHP script (strlen($text) * font-width) which is put in a style="width : <title width>;". But I don't want that, because that would make my page be cluttered with tables.

    Does anyone know of a way by doing this with HTML or CSS or should I use PHP instead?
     
  2. Glaanieboy

    Glaanieboy Moderator

    Messages:
    2,626
    Location:
    The Netherlands
    *cough* *bump*
     
  3. Cirrus

    Cirrus OSNN One Post Wonder

    Messages:
    4
    Location:
    Amsterdam, The Netherlands
    I added a class (border, background-color, etc) on the title-text, instead of the td.
    Probably not what you want, but it's all I can think of right now.
     

    Attached Files:

    • test.zip
      File size:
      757 bytes
      Views:
      45
  4. Glaanieboy

    Glaanieboy Moderator

    Messages:
    2,626
    Location:
    The Netherlands
    Looks good! Thanks ;)