Simple div not wrapping text

February 2, 2010 at 13:35:00
Specs: WinXP, 4GHZ/1GB

I'm having a really annoying problem. I'm using notepad++ to create a html page and viewing it with firefox.

Very, very simple. A div that has the word content repeated inside it. The issue i have comes from the text not wrapping to flow down the div and expamnd the height automatically. It flows off to the right beyond and outside the div.

What am i doing wrong, its such simple error its driving me nuts!


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="" dir="ltr" lang="en-US">

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />


<style type="text/css">
margin: 0;
padding: 0;
#content {
width: 150px;
border: 1px solid gray;
height: 100%;
<div id="content">


See More: Simple div not wrapping text

Report •

February 2, 2010 at 23:29:43
It's doing what it's supposed to do. :P Your div is only 150px wide, so any long string will overflow the border. It would *probably* break if there were a white space before it flowed outside of the div.

A few *possible* fixes (surely there's others)

If you don't mind scroll bars, you could try adding overflow: auto or perhaps overflow: scroll

you could try adding a <p> tag to contain the text.

if you've got access to server side scripting, you could try a word wrapping function; for example, php has the function wordwrap, which would split any long words up a char count boundary or possibly a special case char such as '\n', <br />, etc.


Report •

February 3, 2010 at 04:02:07
oh bugger.

You know I've spent too long working with cms stuff I forgot. Late night and too much coffee. Was working with wordpress and thats why it was wrapping!

What noob. Thanks though.



Report •

February 3, 2010 at 04:17:52
Ah I can't believe I couldn't see that it had no spaces in. I am hanging my head in shame right now


Report •

Related Solutions

February 3, 2010 at 15:00:14
lol - long nights will do it. :)

I can't count the number of times I've just sat there pondering why a function or something wouldn't work when all it was a typo. :O


Report •

Ask Question