Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

valid html header

Is there any way to write a valid header/link/image? Something like

<a href="index.html"><h1 id="logo">Company name</h1></a> 

(with an image set as background and the text moved way to the left so its not visible via css)

like image 533
doug Avatar asked Apr 16 '26 07:04

doug


2 Answers

Something like:

<h1 id="logo"><a href="index.html">Company Name</a></h1>

#logo a {
    display: block;
    width: 200px; /* width and height equal to image size */
    height: 100px;
    background: transparent url(images/logo.png) no-repeat;
    text-indent:-9999px;
}

The problem with you original markup is that <a> is an inline element and <h1> is a block element. An inline element cannot contain a block element.

like image 90
roryf Avatar answered Apr 18 '26 20:04

roryf


No, anchor elements cannot contain h1 elements.

Also, background images should be reserved for backgrounds - a logo is not a background, it is important information.

<h1><a href="/"><img src="/images/logo.png" alt="Company Name"></a></h1>

Remember that, while the identity of the company is probably the most important heading on the homepage, it probably is not on other pages - so the should usually be downgraded to a elsewhere.

like image 37
Quentin Avatar answered Apr 18 '26 20:04

Quentin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!