Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Mar 18th, 2006, 4:20 AM   #1
Writlaus
Hobbyist Programmer
 
Writlaus's Avatar
 
Join Date: Nov 2005
Posts: 149
Rep Power: 3 Writlaus is on a distinguished road
table size limits

I know you can set the td widths and such, but when a word is too long, it just stretches the cell. For example...

<table width=100%>
    <tr>
        <td width=20%>
            [put a reeeeeeally long word here]
        </td>
    </tr>
</table>

That td cell will be as long as that word is, unless the word is smaller than the cell. Is there any way to fix that? I know PHP, in case that could be part of the solution.
Writlaus is offline   Reply With Quote
Old Mar 18th, 2006, 4:56 AM   #2
Agent 47
Hobbyist Programmer
 
Agent 47's Avatar
 
Join Date: Nov 2005
Posts: 122
Rep Power: 4 Agent 47 is on a distinguished road
It's stretching because there is no white-space in long words
for the browser to wrap. There is no solution bar splitting the
word up and hyphenating it.
__________________
"I'm going to become rich and famous when I invent a device that allows you to stab people in the face over the internet"
Agent 47 is offline   Reply With Quote
Old Mar 18th, 2006, 4:58 AM   #3
Polyphemus_
Expert Programmer
 
Polyphemus_'s Avatar
 
Join Date: Aug 2005
Location: Rotterdam, the Netherlands
Posts: 942
Rep Power: 4 Polyphemus_ is on a distinguished road
You can use the CSS overflow property, or you can use PHP's wordwrap function: http://nl2.php.net/wordwrap, which splits long words into smaller words.
Polyphemus_ is offline   Reply With Quote
Old Mar 18th, 2006, 5:12 AM   #4
Writlaus
Hobbyist Programmer
 
Writlaus's Avatar
 
Join Date: Nov 2005
Posts: 149
Rep Power: 3 Writlaus is on a distinguished road
Arg. I was hoping there was some table attribute or something, so I wouldn't have to go and write my own wordwrap method (since I want it to wrap when the word gets to a certain pixel length, rather than a certain character amount).
Writlaus is offline   Reply With Quote
Old Mar 18th, 2006, 5:19 AM   #5
Agent 47
Hobbyist Programmer
 
Agent 47's Avatar
 
Join Date: Nov 2005
Posts: 122
Rep Power: 4 Agent 47 is on a distinguished road
Quote:
Originally Posted by Writlaus
(since I want it to wrap when the word gets to a certain pixel length, rather than a certain character amount).
You'll not be able to do that in PHP then, as you have no way to
tell how many pixels the word will occupy in the client's browser.
It is probably possible in JavaScript, but it'll be ugly...
__________________
"I'm going to become rich and famous when I invent a device that allows you to stab people in the face over the internet"
Agent 47 is offline   Reply With Quote
Old Mar 18th, 2006, 7:55 AM   #6
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Besides, what happens when the user adjusts (or tries to adjust) the text size in the browser? Changes resolutions? Resizes a window? Personally, I try to leave the user in control as much as possible while still having a presentable page.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Mar 18th, 2006, 8:39 PM   #7
mackenga
Professional Programmer
 
Join Date: Mar 2005
Location: Glasgow, Scotland
Posts: 317
Rep Power: 4 mackenga is on a distinguished road
I must say I don't envy anyone trying to do something pixel-perfect with HTML. If you're starting to worry about the width in pixels of a character, you've got a fundamental design problem. You can't do it at all without incredibly hairy goings-on with server-side code and doing it in JS is no easier (and until MS pull their socks up "portable Javascript" is an oxymoron anyway). You'd almost be as well simulating a table that behaved the way you wanted it to with a Java applet.

(Don't do this by the way, it would be insane.)
mackenga is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 10:50 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC