Can I prevent text in a div block from overflowing?
<div id="myDiv">
stuff
</div>
#myDiv {
overflow:hidden;
}
Give that a try. And check out the docs for the overflow property.
I think your question is answered in the documentation of the css overflow
property.
Yes. You can use CSS - There are a bunch of values you can use..
http://www.w3schools.com/Css/pr_pos_overflow.asp
inkedmm is right, that might be the behavior you want, but you should determine if that is the case.
.NonOverflow
{
width: 200px; /* Need the width for this to work */
overflow: hidden;
}
<div class="NonOverflow">
Long Text
</div>
You can control it with CSS, there is a few options :
- hidden -> All text overflowing will be hidden.
- visible -> Let the text overflowing visible.
- scroll -> put scroll bars if the text overflows
Hope it helps.
If your div has a set height in css that will cause it to overflow outside of the div.
You could give the div a min-height if you need to have it be a minimum height on the div at all times.
Min-height will not work in IE6 though, if you have an IE6 specific stylesheet you can give it a regular height for IE6. Height changes in IE6 according to the content within.
If you want the overflowing text in the div to automatically newline instead of being hidden or making a scrollbar, use the
word-wrap: break-word
property.