Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Non-clickable areas in multi-line HTMLanchors

Tags:

html

css

Is it possible to prevent non-clickable area between lines in a multi-line html anchor tag? Here in this example I use line height 1.5 and you can't click between lines.

I know in html5 we can put block-level tags in anchor like <a><div>Link</div></a> but the problem is this part of content can be edited by users and I can't ask them to write their anchor links like this. Is it possible to fix this issue with css only?

CSS:

a {
    line-height:1.5em;
}

HTML:

<a href="#">This is a <br> multiline anchor</a>
<br><br><br>
<a href="#">This is a very long anchor displayed as a multiline anchor without BR</a>

DEMO:

http://jsfiddle.net/ergec/F52uY/2/

like image 355
Ergec Avatar asked Dec 09 '22 11:12

Ergec


1 Answers

You can set display: inline-block; or display: block to a, and then it will be clickable.

Example: http://jsfiddle.net/RMXfc/

Or you can increase padding and set negative margin at the same time. This will reduce gap.

Example: http://jsfiddle.net/693z4/

like image 69
Krzysztof Avatar answered Dec 31 '22 15:12

Krzysztof