HermanMartinus / bearblog

Free, no-nonsense, super fast blogging.
MIT License
2.36k stars 73 forks source link

Consider placing anchor within blog title h1 #266

Closed leonp closed 7 months ago

leonp commented 7 months ago

HI!

The markup for the blog title and the link back to the home page is:

<a class="title" href="/">
<h1>
Blog title
</h1>
</a>

While this is valid HTML, as a is an inline element, does it make more sense to put it within the h1?

<h1>
<a class="title" href="/">
Blog title
</a>
</h1>

This CSS would ensure the link fills the space of the whole h1:

.title {
    display: block;
}

Also wondering whether this affects how a screen reader relays the page?

Thanks,

Leon

HermanMartinus commented 7 months ago

Hey Leon, thanks for the suggestion.

Both options are technically valid. Your suggestion makes sense, but changing the structure of the HTML will break stylesheets for all users who've used the selector .title h1 and similar.

There is very minimal to negligible upside in changing the format, but unfortunately a lot of downsides. The current setup has been tested to work with all major screen readers as well, so we're good on that front.