Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Link text larger than parent

Tags:

html

css

I have a div, and inside that div is a link

<div class="something">
<a href="#">Databases</a>
</div>

The problem is that when I set the width of my div, smaller then the width that the text of the link is. the text of the link just goes outside of the parent div.

What I want is that the text breaks to a new line.

How can I fix this ?

like image 334
Nealv Avatar asked Dec 10 '25 21:12

Nealv


2 Answers

Use the CSS word-break rule.

a {
    word-break:break-all;
}

jsFiddle example

like image 128
j08691 Avatar answered Dec 13 '25 09:12

j08691


Try this

a{
    white-space: pre-wrap;
    word-wrap: break-word; 
}

JsFiddle Demo

like image 26
Sachin Avatar answered Dec 13 '25 09:12

Sachin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!