Making an h2 tag with a strong tag inside accessible

后端 未结 3 1559
清歌不尽
清歌不尽 2021-01-24 18:55

So this may seem like a very simple question but I can\'t get my head around it. I have the following HTML:

word 1 - word 2

3条回答
  •  抹茶落季
    2021-01-24 19:34

    Having a strong in a h2 can be perfectly fine. But it depends on the actual content if strong is appropriate. It’s not appropriate if you only need it to make the text bold.

    Look at all of the text-level semantic elements. Use the span element (because it’s meaningless) if no other element is suitable.

    The way screen readers read this heading has most likely nothing to do with strong in particular, but it’s just the way some screen readers behave when they encounter an element (may it be strong, span, or whatever). You don’t have to worry about this. Screen reader users know and expect this, and they have ways to change this if they want to.

提交回复
热议问题