Question

I have a header and I would like to create a back to homepage link from it. Is it a mistake if I do this?

<a href="index.php?menuid=1" title="Go back to the homepage.">
   <header>
       <h1>Title of the page</h1>
   </header>
</a>

If it's better to create link from the <h1> then how to expand the link to the size of the header? Because the link on it looks like this:

Image

Was it helpful?

Solution

If you want the entire header to be a link, that is the correct way to do it (at least in modern HTML5 browsers). If you want your <h1> to be the full width of <header> then add

h1 {
  width: 100%
}

to your CSS (though you should add an id or class to the h1 and select through that, better than a general h1).

OTHER TIPS

Adding my answer for what is worth (also updated you fiddle)

header{
    display:block;
    height:210px;
    width:560px;
    text-align:left;
    background-color:#eb4172;
    border: 20px solid transparent;
}
h1 {
    background-color:#00aaff;
    width:100%;
    height:100%;
    display:block;
}

h1 a{
    width: 100%;
    display: block;
    height: 100%;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top