lpbug lpbug - 1 year ago 58
CSS Question

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

In this example The div with id

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


Answer Source

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

add display: block as css to the a tag.

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download