Page 1 of 1

CSS: Width of a link

Posted: Thu Nov 27, 2008 10:34 pm
by JKM
I'm a bit stuck here with my CSS.

#blabla a {
width: 150px;
}

<div id="blabla">
<a href="#">fgdfg</a>
</div>

But the link won't be 150px wide. I've tried span, p, tt and so on, but it won't help. The link is inside a list, but I've got other styling for the list, so that won't work.

Re: CSS: Width of a link

Posted: Fri Nov 28, 2008 4:06 am
by mintedjo
Hi
I'm not sure if this is considered bad code or anything but last night I used:

Code: Select all

a{display: block; width: 100px;}
To set the width of a link.
Seems to work for me.

Re: CSS: Width of a link

Posted: Fri Nov 28, 2008 10:48 am
by pickle
An <a> element is inline. As a result, you can't set it's width. Setting it to display as a block element (such as ~JKM suggested) or floating it will allow you to set it's width.