|Div tag and long URL - Firefox does not keep fixed width|
simple question, really
I've got a real simple question on div tags. I have a div that is fixed width, and it has a bunch of text posted in it by users (say, like a blog). If user posts a long URL, I will get different behavior in Firefox and IE - in IE a div with fixed width will stay the same (text will wrap), however in Firefox it expands to as long as a URL is, messing up other design.
Correction, there's a div, then table inside with 2 columns, top one has a "header" - different color, etc., bottom row is text.
Question of the day - how do I fix it? I like how IE behaves in this case - width stays the same and doesn't expand. Can this be fixed for Firefox?
|...in IE a div with fixed width will stay the same (text will wrap), however in Firefox it expands to as long as a URL is, messing up other design. |
Are you sure the DIV is expanding, or may be the contents is spilling out of the container? In my experience IE will tend to stretch the DIV container to make its contents fit - certainly if the contents is a table that refuses to wrap?
If you want to fix the width of your DIV container, you might need to add overflow:hidden to your DIV. However, any content that spills out of your DIV will not be visible.
yes, you are correct,content is actually silling over DIV. Any idea on how to prevent that?
To prevent the content spilling out of the DIV, ie. to fix the width of the DIV and not let it expand, you need to set overflow:hidden on the DIV. However, the content is still unlikely to fit, you just won't see anything that is outside the bounds of your DIV container.