fmz 14

I am working on a page that I would like to use a graphic as a background image for an h1 element at the top of the page and I would like it to link to the home page.

I tried this code, which works, but W3C validator does not like my syntax:

Here is the code:

<a href="index.html"><h1>J Lloyd Morgan</h1></a>

Here is the css:

background: url(../_images/logo.png) no-repeat left top;

Here is the error:

Line 37, Column 46: document type does not allow element "h1" here; missing one of "object", "applet", "map", "iframe", "button", "ins", "del" start-tag

I would appreciate some guidance on how to get this to link to the home page and validate too.


1 answer

This was chosen as the best answer

Put the link inside the <h1> and it will validate


<h1><a href="index.html">J Lloyd Morgan</a></h1>

and set the link to display:block and size it to suit your background image

Answered over 9 years ago by Tony Crockford
  • Tony, thank you. You have resolved a long-standing issue for me. Works perfect. fmz over 9 years ago