Use Label a as a container

2

Good morning, I'm doing an exercise with HTML and I have a doubt, I'm enclosing a label <a> a <div> and within this same there is a label <p> and other <img> and it works well and as I want, my query is, is it correct to do so according to web standards?

<a href="enlace">
	<div>
		<p>texto</p>
		<img src="img.png">
	</div>
</a>
    
asked by jose marquez 25.02.2018 в 20:20
source

1 answer

3

Depends on the version of HTML you use is considered correct or not:

  • In HTML5 : it is allowed to have almost any type of content within a a tag: block or inline elements, as long as they are not interactive elements (eg other links or buttons). So it is correct to have a div , p or img within a .

  • In previous HTML versions : it would not be allowed to have a div within a a because only inline elements could be had (and div is a block element) to exclude interactive elements like other a . So in the case that you expose would not allow div or p but yes img because it is inline.

Source / Bibliography:

answered by 25.02.2018 в 20:38