**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 wrap the header around the anchor, you create a large anchor, only the text will be clickable.  
- When you wrap the anchor around the header, the whole line get's clickable.

[I've made you an example on jsFiddle.net][1]


  [1]: http://jsfiddle.net/yj8652x7/