
Originally Posted by
adoxe
Some of that content is unreadable when the background images aren't rendered. An explicit background colour should usually accompany such images.
XHTML is usually a waste of time, especially if you're always serving it as HTML. Still, your markup wouldn't be valid HTML, either.
<div id="button_one_inside" style="width:100%;height:100%">
Just so you're aware, this is equivalent to:
Code:
<div id="button_one_inside" style="width: 100%;">
A percentage value for the height property must eventually be calculated against an explicit length. For example,
Code:
<div>
<div style="height: 60%;">
<div style="height: 110%;">
might as well be:
However,
Code:
<div style="height: 10em;">
<div style="height: 60%;">
<div style="height: 110%;">
would be computed to:
Code:
<div style="height: 10em;">
<div style="height: 6em;">
<div style="height: 6.6em;">
On a similar line, the width property declaration is unnecessary. Block-level elements automatically take up as much horizontal space as they can within their containing blocks. Trying to force 100% width will only cause problems if you add padding, borders, or margins, as these areas will cause the element to overflow.
is there a simple way to make a complete zone clickable without using such a pattern (div in an anchor) ?
Yes. Style the link (a) into a block-level element. It will then take all horizontal space, and expand vertically to contain its contents. This should also mean you can remove the outer div element, too.
Code:
.button {
display: block;
}
<a class="button" href="..."><img alt="..." src="..."> Button text</a>
Mike
Bookmarks