Powered By Blogger

Monday, August 19, 2013

CSS - Why am I not able to set height and width of "a href" elements?


As the others have said, by default <a> is an inline element, and inline elements can't specify a width or height. You can change it to be a block element like this:

a {
    display: block;
}
Though it will then display (unsurprisingly) as a block, sitting on its own, outside the flow of the surrounding text. A better solution is to use display: inline-block which might be a best-of-both-worlds solution depending on your situation.

No comments:

Post a Comment