Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

link text sticks out of the div

Tags:

css

to make it simple, i've got following code:

<div>
     <a>view all your links</a>
</div>

the width of the div is very small so the text "all your links" sticks out of the div. how do i do to have a new line after "all your" so "links" dont stick out?

like image 555
ajsie Avatar asked Sep 01 '25 03:09

ajsie


2 Answers

If you want to break links visually so they don't extend out of a div, you can add word-wrap: break-word to a in your stylesheet. Thus:

a {
    word-wrap: break-word;
}
like image 177
Matt Avatar answered Sep 02 '25 16:09

Matt


You have not specified your desired result. Do you want the div to resize to accomodate the entire width of the links? If so, don't put a fixed width on it or any of its ancestor elements. Do you want the overlong links to be cut off? If so, put overflow: hidden in the style of the div.

like image 25
glomad Avatar answered Sep 02 '25 17:09

glomad