Reputation: 47945
I have this div:
<div class="text">
Thisismytextwontgoinanewparagraph
</div>
with this CSS:
.text
{
background-color:red;
width:100px;
}
As you can see in this JSFiddle, the text goes outside of the div.
Is there a way in CSS to force wrapping for a text without spaces (such as a hyperlink)?
Upvotes: 2
Views: 8868
Reputation: 740
Why not just use ellipsis with overflow hidden? That will also look pretty.
.text {
background-color: red;
width: 100px;
overflow: hidden;
text-overflow: ellipsis;
}
Upvotes: 0
Reputation: 1
Here is how I did it. I added the <br>
tag to the text I wanted to push to the next line.
<p> Sleek custom designs and durable functionality. <br>Let your headwear work for you. </p>
text multiple lines example
Upvotes: -1
Reputation: 10997
you could try this, but it's not very pretty:
.text
{
background-color:red;
width:100px;
word-wrap: break-word;
}
Upvotes: 5