Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Text expands outside the div it's inside?

Tags:

html

css

I've got this code:

<html>
<head>
<style type="text/css">

body {
    text-align: center;
}

#content {
    width: 60em;
    margin: 0, auto;
    background-color: #CCC;
}

</style>
</head>

<body>
<center>
<div id="content">kdsjlglkdfjgolksdjflgojsdfsdoljfglsdfghsdkjfgkdhfgkhlglkdfjgolksdjflgojsdfsdoljfglsdfghsdkjfgkdhfgklglkdfjgolksdjflgojsdfsdoljfglsdfghsdkjfgkdhfgklglkdfjgolksdjflgojsdfsdoljfglsdfghsdkjfgkdhfgklglkdfjgolksdjflgojsdfsdoljfglsdfghsdkjfgkdhfgklglkdfjgolksdjflgojsdfsdoljfglsdfghsdkjfgkdhfgklglkdfjgolksdjflgojsdfsdoljfglsdfghsdkjfgkdhfgklglkdfjgolksdjflgojsdfsdoljfglsdfghsdkjfgkdhfgkkjdghkdsfjgksdjfhg</div>
</center>
</body>

</html>

Why does the text not stay inside the div, but go in a single line until it ends? I want it to have line breaks relative to the div it's inside. How can I do this?

like image 428
DarkLightA Avatar asked Dec 09 '22 12:12

DarkLightA


1 Answers

Because word wrapping occurs between words.

At least by default. The word-break property can change that in some browsers, but you should avoid having nonsensical 'words' in the content.

like image 126
Quentin Avatar answered Dec 30 '22 16:12

Quentin