Re: 4 Errors but syntax is correct

Many thanks for the time spent and the nice explanation. I will adapt the passage with the suggestions. đź‘Ť

> Am 04.08.2020 um 14:34 schrieb Jukka K. Korpela <jukkakk@gmail.com>:
> 
>  Dandy Rose (dandy86.rose@gmail.com <mailto:dandy86.rose@gmail.com>) wrote:
> 
> in my example are 4 errors that elements are not opened or closed correctly, but the syntax is perfectly ok. 
> This only happens if the headline is inserted inside the anchor. But this should be allowed in HTML5
> 
> HTML5 allows heading elements like <h5> within an <a> element, but only when the parent element allows it. The content model of <a> is “transparent”.
> https://html.spec.whatwg.org/multipage/text-level-semantics.html#the-a-element <https://html.spec.whatwg.org/multipage/text-level-semantics.html#the-a-element>
>  
>         <p><a href="#" target="_blank"><h5>TEST</h5></a><p>
> 
> Without <p> markup (which is rather pointless here), this would be valid, since then the parent of <a> would be <body>, which allows <h5>. But here the parent is <p>, which allows only “flow content”, which is more or less what used to be called “text-level markup”. 
> 
> So the simplest solution it to remove the first <p> tag. If you need a container for the <a> element, use e.g. <div>.
> 
> Note that you could also next <a> and <h5> the other way around:
> <h5><a href="#" target="_blank">>TEST</a></h5>
> Such nesting has been valid in all versions of HTML. The practical difference between this and your nesting is that this makes only the heading text, “TEST”, clickable, whereas your nesting makes the entire heading block (which by default occupies the available width, including any empty space to the right of the heading text.
> 
> Jukka

Received on Tuesday, 4 August 2020 20:42:13 UTC