tags:

views:

37

answers:

2

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?

+1  A: 

Use the max-width property for your a links.

Edit: You'll likely need a display: block for your a tag as well.

ghoppe
the links are inserted into the div with ajax. and the link texts are selected from database.
weng
This is still a valid answer to solve the problem as far as I can see.
Jamie Dixon
To avoid confusion let me state I edited my answer after noname clarified his question.
ghoppe
it doesnt work!..used max-width and display block. the backgroundcolor got chopped not the text inside of it.
weng
without more information as to the rest of your code and css, i don't know what to say, as my quick experiment works: div {background: #666;width:200px;} a {display: block; max-width: 120px;} Browser bug? What browser are you using?
ghoppe
my fault. i had nowrap on the links=/
weng
+1  A: 

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.

ithcy