mickeymouse Posted May 19, 2012 Share Posted May 19, 2012 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. Link to comment Share on other sites More sharing options...
Ingolme Posted May 19, 2012 Share Posted May 19, 2012 Try setting the white-space property to "nowrap" in all the table cells. Link to comment Share on other sites More sharing options...
mickeymouse Posted May 19, 2012 Author Share Posted May 19, 2012 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\"> Link to comment Share on other sites More sharing options...
Ingolme Posted May 19, 2012 Share Posted May 19, 2012 Just CSS: td { white-space: nowrap} This makes the table be exactly as wide as the content in it, without any line breaks. Link to comment Share on other sites More sharing options...
mickeymouse Posted May 20, 2012 Author Share Posted May 20, 2012 Beautiful!Many thanksMickey Link to comment Share on other sites More sharing options...
amitamberker Posted May 20, 2012 Share Posted May 20, 2012 Hi mickeymouse,Could you please show me your design? I would like to know why and where have you used width="5000"... Link to comment Share on other sites More sharing options...
amitamberker Posted May 20, 2012 Share Posted May 20, 2012 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. Link to comment Share on other sites More sharing options...
Ingolme Posted May 21, 2012 Share Posted May 21, 2012 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. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now