Your question refers to <header>
element but the CSS code uses a class selector #header
. Technically you could have <header class=header>
, but that would be rather pointless, and #header
suggests that the actual markup has <div class=header>
.
Both a <header>
element and a <div>
element can be placed inside an <a>
element, as far as actual browser behavior is considered. HTML specifications have traditionally disallowed such constructs, but HTML5 CR allows any “flow content” inside <a>
.
If the header is really just one image (as a background image), then it would appear to be more natural to use just an a
element and set the background image directly on it. However, this reduces accessibility, because there is no way to specify alternate text for a background image, so to screen readers and to browsers with image loading disabled, there would be a link with no content, no link text. Therefore, if the header should be a link, it is better to use a content image, e.g.
<header>
<a href="./"><img src=hdr.png alt="ACME Company" border=0></a>
</header>
(However, a content image forces the minimal page width to the width of the image. This is not always desirable, but that’s a different story and different question.)