Cut off text if its too big for a table? (Resize table?)

I made a nice (imo), custom table for my posts while following a simple blog in Rails tutorial. I was wondering tho if I can set a maximum width for a table row/cell and have it cut off text if its too long to fit, so it just shows a preview of the blog post. Also, is it possible for the table to size and get bigger with the resizing of a browser window? I know that this is mostly an HTML problem, so I'm sorry if this is the wrong place.

There should be a way to just limit the number of words displayed from a certain field. Do it that way and then you'll have some consistency. I can't think at the moment, but I would think there is a way to limit the number of words to just a certain limit relatively easily in Ruby/ Rails.

Hi Tim,

I made a nice (imo), custom table for my posts while following a simple blog in Rails tutorial. I was wondering tho if I can set a maximum width for a table row/cell and have it cut off text if its too long to fit, so it just shows a preview of the blog post. Also, is it possible for the table to size and get bigger with the resizing of a browser window? I know that this is mostly an HTML problem, so I'm sorry if this is the wrong place.

I can think of a couple of ways to approach this.

CSS overflow - not sure if this works with table elements, but you can set the overflow attribute in a CSS rule to simply clip content to the element size, make the element scroll, or a couple of other choices.

Helper methods - either a view helper, or a method in your model, can trim the string prior to display; assuming you know the size you want to trim it to.

I prefer the CSS approach because it's simpler. It'll automatically take care of the resizing issue. But, like I said, I'm not sure if it's supported with table elements. Make a test and let us know.

HTH, Bill