They're both correct in html5, html allows block elements in inline elements. This also has no effect on SEO, both cases the text is wrapped in the heading, so it remains to have the same value.
It's not a choice of validness, but a preference in User Interface:
- If you wrapWrapping the header around the anchor, you create a large anchor, only: Only the text will beis clickable.
- When you wrapWrapping the anchor around the header, the: The whole line get'sheader row turns clickable.