All Posts by Email, Once a Week

Media Temple logo

CSS-Tricks is brought to you in part by Media Temple, the web hosting that we both use and recommend.

set max characters inside table cell?

  • # June 4, 2009 at 7:02 am

    Hi CSSers,

    I have a table with table-layout:fixed property with 5 headers <th>. How do I set the data cells <td> within each of the headers to have a maximum character allowed? I tried ‘maxlength’ but it didn’t work.

    Is there a property I’m missing out?

    Thank you very much!

    # June 4, 2009 at 11:44 am

    Max characters allowed? You mean before the line breaks down (<br>)?

    Or do you mean total allowed characters in a cell?

    The first one can simply be done by setting a width on the cell.

    td {

    The latter will need to be done with some sort of PHP I’d assume. Some sort of trim function.

    # June 5, 2009 at 1:33 am

    Thanks Doc!

    I was going for the 2nd one, which is total characters allowed.

    At the moment I got a fixed table-layout and applied this to the td:
    table td {
    border-bottom:1px solid #fff;
    border-left:1px solid #fff;
    border-top:1px solid transparent;


    I think I gotta go with the php thing, a friend will help me with that.

    Thank you!

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.

There's a whole bunch of content on CSS-Tricks.

Search for Stuff   •   Browse the Archives

Get the Newsletter ... or get the RSS feed