Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

For my website I have a checkbox with a label next to it, but if the text in the label is longer than for example 60px, I want to cut off the text.

I know about the text-overflow: clip, this does exactly what I want, but for some reason it doesn't work on a label. And using a div instead isn't a really good solution, since you can't click on the text to select the checkbox then.

How can I do this?

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

label or span are inline by default. You cannot set width on inline elements. So make label inline-block

/// markup

<input type="checkbox"/> <label style="display: inline-block; width: 60px; overflow: hidden">Sample text sample text</label>
share|improve this answer
    
Add text-overflow: clip to it, so the ... appears at the cut-off. –  LinkinTED Oct 6 '13 at 11:14
    
Yep. missed it. Thanx LinkinTED :) –  Arun Aravind Oct 6 '13 at 11:15
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.