Make WordPress Core

Opened 5 years ago

Last modified 4 years ago

#50202 new defect (bug)

Use <strong> tag instead of <b> tag in `Walker_Comment::html5_comment`

Reported by: itowhid06's profile itowhid06 Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version:
Component: Comments Keywords: needs-patch
Focuses: accessibility Cc:

Description

It is well documented that when some text is bolded using the <b> tag, it will come to no benefit for users using screen readers. This patch aims to fix that in an instance of html5_comment method in Walker_Comment.

Attachments (1)

50202.diff (635 bytes) - added by itowhid06 5 years ago.

Download all attachments as: .zip

Change History (4)

@itowhid06
5 years ago

#1 @SergeyBiryukov
5 years ago

  • Keywords close 2nd-opinion added

Thanks for the patch! The <b> tag was introduced in [24539] / #24522 and is only used here as a wrapper for comment author name, not to signify importance.

Per the HTML standard, this appears to be valid usage:

The b element represents a span of text to which attention is being drawn for utilitarian purposes without conveying any extra importance and with no implication of an alternate voice or mood, such as key words in a document abstract, product names in a review, actionable words in interactive text-driven software, or an article lede.

Per MDN web docs, too:

The HTML Bring Attention To element (<b>) is used to draw the reader's attention to the element's contents, which are not otherwise granted special importance.
...

  • Use the <b> for cases like keywords in a summary, product names in a review, or other spans of text whose typical presentation would be boldfaced (but not including any special importance).
  • Do not confuse the <b> element with the <strong>, <em>, or <mark> elements. The <strong> element represents text of certain importance, <em> puts some emphasis on the text and the <mark> element represents text of certain relevance. The <b> element doesn't convey such special semantic information; use it only when no others fit.

This ticket was mentioned in Slack in #accessibility by afercia. View the logs.


5 years ago

#3 @afercia
5 years ago

  • Keywords needs-patch added; has-patch close 2nd-opinion removed
  • Milestone changed from Awaiting Review to Future Release
  • Version trunk deleted

This ticket was discussed during today's accessibility bug-scrub.

While it's true the usage of a <b> element in this case is not incorrect, it is also true that right now the commenter username has no specific semantics. For example, screen readers would read it as normal text. It would be nice to add some semantic, not sure a <strong> element would be appropriate though. Also, there are backwards compatibility concerns. Moving to future release for now, pending some research and investigation.

Last edited 4 years ago by afercia (previous) (diff)
Note: See TracTickets for help on using tickets.