Stop auto size of table cells?

Discussion in 'HTML' started by harry, May 14, 2004.

  1. harry

    harry Guest

    Is there anyway to prevent a table cell from expanding to fit all the data
    in it? i.e the datas 50 char's long but I only want to display the 1st 10
    chars?

    thanks

    harry
    harry, May 14, 2004
    #1
    1. Advertising

  2. harry wrote:
    > Is there anyway to prevent a table cell from expanding to fit all the data
    > in it? i.e the datas 50 char's long but I only want to display the 1st 10
    > chars?


    I couldn't get it to work with the td directly, probably because the
    table has ideas of its own about its width. But wrapping the content in
    a suitable container should work, e.g

    p {width:5em; overflow:hidden}

    And in CSS there's no unit for the width of a character. But 5em should
    be close enough, just adjust the value until you're happy with it.

    See <http://www.w3.org/TR/CSS2/visufx.html#propdef-overflow> for other
    overflow values.


    Matthias
    Matthias Gutfeldt, May 14, 2004
    #2
    1. Advertising

  3. harry

    harry Guest

    Thanks Matt, found this also style="table-layout:fixed;" which displays as
    many as possible but chops off the remaining - just what I wanted!

    cheers!


    "Matthias Gutfeldt" <> wrote in message
    news:...
    > harry wrote:
    > > Is there anyway to prevent a table cell from expanding to fit all the

    data
    > > in it? i.e the datas 50 char's long but I only want to display the 1st

    10
    > > chars?

    >
    > I couldn't get it to work with the td directly, probably because the
    > table has ideas of its own about its width. But wrapping the content in
    > a suitable container should work, e.g
    >
    > p {width:5em; overflow:hidden}
    >
    > And in CSS there's no unit for the width of a character. But 5em should
    > be close enough, just adjust the value until you're happy with it.
    >
    > See <http://www.w3.org/TR/CSS2/visufx.html#propdef-overflow> for other
    > overflow values.
    >
    >
    > Matthias
    >
    harry, May 14, 2004
    #3
    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. Replies:
    0
    Views:
    513
  2. bbxrider
    Replies:
    0
    Views:
    595
    bbxrider
    Jul 14, 2003
  3. UJ
    Replies:
    8
    Views:
    61,131
  4. linkswanted
    Replies:
    1
    Views:
    886
  5. Joel Finkel

    Cells[].Text or Cells[].Controls[0]

    Joel Finkel, Sep 1, 2003, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    297
    Joel Finkel
    Sep 1, 2003
Loading...

Share This Page