Jump to content
Sign in to follow this  
mickeymouse

Table Width

Recommended Posts

W3Schools says "If the width attribute is not set, a table takes up the space it needs to display the table data. Problem: I have no width attribute but the width displayed is only a bit more than the screen width and it takes 3 rows to display the data instead of displaying all in one row. I do not have a CSS defining the width. If I define the width in the table tag as width="5000", my data iscorrectly displayed in one row. But I don't want to use this methodbecause the length of my row is variable from one user to another.

Share this post


Link to post
Share on other sites

Try setting the white-space property to "nowrap" in all the table cells.

Share this post


Link to post
Share on other sites

Tried it but doesn't work.Is this what you meant?<input readonly size=\"10\" style=\"white-space:nowrap;color:maroon;text-align:left\" value=\"Date\"><input readonly size=\"33\" style=\"white-space:nowrap;color:maroon;text-align:left\" value=\"Description\"><input readonly size=\"10\" style=\"white-space:nowrap;color:maroon;text-align:right\" value=\"Amount\"> <input readonly size=\"15\" style=\"white-space:nowrap;color:maroon;text-align:left\" value=\"From Account\"><input readonly size=\"15\" style=\"white-space:nowrap;color:maroon;text-align:left\" value=\"To Account\">

Share this post


Link to post
Share on other sites

Just CSS:

td {   white-space: nowrap}

This makes the table be exactly as wide as the content in it, without any line breaks.

Share this post


Link to post
Share on other sites

Hi mickeymouse,Could you please show me your design? I would like to know why and where have you used width="5000"...

Share this post


Link to post
Share on other sites
Just CSS:
td {   white-space: nowrap}

Hi Ingolme,What is this used for? How can I use this in DIV tags? Could you please show me an example? I have never used it.

Share this post


Link to post
Share on other sites
Hi Ingolme, What is this used for? How can I use this in DIV tags? Could you please show me an example? I have never used it.
All it does is prevent text from wrapping in an element. You can use it on any element.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×