# Fixed Sized Columns in TABLE on screen

**URL:** <https://www.ruby-forum.com/t/fixed-sized-columns-in-table-on-screen/170560>\
**Category:** Rails\
**Created:** [June 19, 2009, 12:14am UTC](https://www.ruby-forum.com/t/fixed-sized-columns-in-table-on-screen/170560 "2009-06-19T00:14:12Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ritvvij](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/bbce88/32.png) [@Ritvvij](https://www.ruby-forum.com/u/Ritvvij)\
**Post date:** [June 19, 2009, 12:14am UTC](https://www.ruby-forum.com/t/fixed-sized-columns-in-table-on-screen/170560/1 "2009-06-19T00:14:12Z")

</div>

Hi,

I am attempting to do the following:

1. Have a table with width = 100px
2. Have 4 columns with width = 20px, 30px, 10px, 40px
3. Have the content within the rows word wrapped as per the size of  
their respective columns - 20px, 30px, 10px, 40px

I am using Rails 2.3.2, want to avoid using ready-made plugins.

Can someone advise 🙂

---

<div class="post-metadata">

**Author:** ![Ritvvij](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/bbce88/32.png) [@Ritvvij](https://www.ruby-forum.com/u/Ritvvij)\
**Post date:** [June 19, 2009, 12:16am UTC](https://www.ruby-forum.com/t/fixed-sized-columns-in-table-on-screen/170560/2 "2009-06-19T00:16:59Z")

</div>

Ritvvij wrote:

> Hi,
> 
> I am attempting to do the following:
> 
> 1. Have a table with width = 100px  
> […]

Except perhaps for the word wrapping, this has nothing whatsoever to do  
with Rails. This is a HTML/CSS issue, so look in CSS references for  
answers.

## Best,

Marnen Laibow-Koser  
[http://www.marnen.org](http://www.marnen.org)  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![Ritvvij](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/bbce88/32.png) [@Ritvvij](https://www.ruby-forum.com/u/Ritvvij)\
**Post date:** [June 19, 2009, 12:25am UTC](https://www.ruby-forum.com/t/fixed-sized-columns-in-table-on-screen/170560/3 "2009-06-19T00:25:20Z")

</div>

Yes I know. But… I mentioned Rails may be Rails has some helpers  
which might help me in the process.  
Even in CSS, does someone has some advise?

The word wrap it self has a helper in Rails. function. Word\_wrap.  
Can someone suggest how to refer this word\_wrap  
\<%= word\_wrap ( “sdnglsdngldsngldsngsdsdgdsg”, :line\_width =\> 3 ) %\>  
dint work for me in a view file.  
What am I doing wrong?

On Jun 18, 5:16 pm, Marnen Laibow-Koser \<rails-mailing-l…@andreas-

---

<div class="post-metadata">

**Author:** ![Ritvvij](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/bbce88/32.png) [@Ritvvij](https://www.ruby-forum.com/u/Ritvvij)\
**Post date:** [June 19, 2009, 1:07am UTC](https://www.ruby-forum.com/t/fixed-sized-columns-in-table-on-screen/170560/4 "2009-06-19T01:07:24Z")

</div>

What I have right now is:

| Name | .....

```
</tr>
<% @users.each do |user| %>
<tr class="<%= cycle :odd, :even %>">
    <td><%=h word_wrap(user.full_name, :line_width => 10) %></td>

```

And it does not wrap it… the column size increases 😑

 |
| --- | --- |

---

<div class="post-metadata">

**Author:** ![Ritvvij](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/bbce88/32.png) [@Ritvvij](https://www.ruby-forum.com/u/Ritvvij)\
**Post date:** [June 19, 2009, 12:49am UTC](https://www.ruby-forum.com/t/fixed-sized-columns-in-table-on-screen/170560/5 "2009-06-19T00:49:18Z")

</div>

Ritvvij wrote:

> Hi,
> 
> I am attempting to do the following:
> 
> 1. Have a table with width = 100px
> 2. Have 4 columns with width = 20px, 30px, 10px, 40px
> 3. Have the content within the rows word wrapped as per the size of  
> their respective columns - 20px, 30px, 10px, 40px

Tables do this automatically - what are we missing here?

Programmatically, if you really want to do in the server what your  
browsers  
could do, then word\_wrap( :line\_width =\> 3 ) might be giving you lines  
with 3  
characters, which is hardly what you need. And even if you figured out  
the  
number of characters in 30px, if the browser disagreed then it would  
wrap your  
wrap, and the lines would look disgusting.

–  
Phlip
