lpbug lpbug - 3 months ago 7
CSS Question

Is there a reason why the CSS "clear: both" doesn't work for <a> tags?

In this example The div with id

parent
is not being scaled to the appropriate height. This is fixed when the last element in the parent div with the class
c_b
is styled with
clear:both
. However, if ONLY the
<a>
tag with the class
link
is styled with
clear:both
nothing happens. I am wondering why
clear:both
appears to work correctly if the last element is a div but doesn't work for link elements.

Thanks

Answer

a is an inline tag and a div is a block.

add display: block as css to the a tag.

edit:
Since this is getting some upvotes here's how to add the css:

Add the css as style in the a tag:
<a href="#yourlink" style="display: block;"> My link </a>

Or by adding it to a stylesheet linked from the <head> tag.

Comments