This question already has an answer here:
- Make a div into a link 24 answers
If I have this which is what I want the result to do -
<a href="#"> <div>This is a link</div> </a>
The W3C validator says that block elements shouldn't be placed inside an inline element. Is there a better way to do this?
Pedantic answer: No.
As you've already put on another comment, it's invalid to nest a
div inside an
However, there's nothing preventing you from making your
a tag behave very similarly to a
div, with the exception that you cannot nest other block tags inside it. If it suits your markup, set
display:block on your
a tag and size / float it however you like.