WordPress.org

Make WordPress Core

Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#23250 closed enhancement (wontfix)

make_clickable is not creating title attribute

Reported by: Confridin Owned by:
Milestone: Priority: normal
Severity: minor Version: 3.5
Component: Formatting Keywords:
Focuses: Cc:

Description

Hi,

I discovered the make_clickable function a few time ago. It converts URI, www, ftp and email addresses into links. The regex works fine but doesn't add the title attribute to the link.

For exemple, here is a sample texte

this is a text with a link : http://www.website.com

With make_clickable, a link is added :

this is a text with a link : <a href="http://www.website.com">http://www.website.com</a>

But a correct html link should contains a title attribute, like this

this is a text with a link : <a href="http://www.website.com" title="http://www.website.com">http://www.website.com</a>

The issue comes from those functions (into wp-includes/formatting.php
_make_web_ftp_clickable_cb
_make_url_clickable_cb
_make_email_clickable_cb

_make_url_clickable_cb
This code

return $matches[1] . "<a href=\"$url\" rel=\"nofollow\">$url</a>" . $suffix;

shoulde be replaced by

return $matches[1] . "<a href=\"$url\" title=\"$url\" rel=\"nofollow\">$url</a>" . $suffix;

_make_web_ftp_clickable_cb
This code

return $matches[1] . "<a href=\"$dest\" rel=\"nofollow\">$dest</a>$ret";

shoulde be replaced by

return $matches[1] . "<a href=\"$dest\" title=\"$dest\" rel=\"nofollow\">$dest</a>$ret";

_make_email_clickable_cb
This code

return $matches[1] . "<a href=\"mailto:$email\">$email</a>";

shoulde be replaced by

return $matches[1] . "<a href=\"mailto:$email\" title=\"$email\">$email</a>";

Do you think it should be corrected ?

Regards,

Daniel Roch.

Change History (10)

#1 @scribu
5 years ago

  • Keywords reporter-feedback added

What's the benefit of duplicating the URL in the title attribute? There can surely be no SEO benefit.

#2 @Confridin
5 years ago

The title attribute is used for accessibility, including several softwares using it to read a link for blind people.

It is also recommanded in the W3C standard.

#3 @Confridin
5 years ago

  • Keywords reporter-feedback removed

#4 @helen
5 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from new to closed

The link text would be read by a screenreader - no need for a title, especially one that doesn't give any more information. Unnecessary title attributes are actually quite detrimental for accessibility: http://www.rnib.org.uk/professionals/webaccessibility/wacblog/Lists/Posts/Post.aspx?id=38

#5 @Confridin
5 years ago

  • Keywords dev-feedback added
  • Resolution wontfix deleted
  • Status changed from closed to reopened

Thanks for your answer Helen. For urls links, it really makes sense.

Should email and FTP links use a meaningful title attribute, like "send an email to" or "ftp connexion to" ? (for _make_web_ftp_clickable_cb and _make_email_clickable_cb).

#6 @SergeyBiryukov
5 years ago

  • Component changed from General to Formatting
  • Milestone set to Awaiting Review

#8 @esmi
5 years ago

Title attributes are almost always a terrible idea

Loudly seconded!

Most experienced screen reader users use their software in non-verbose mode - which means that title attribute rendering is turned off. As an aside, this is almost certainly the result of sites in the past using title attributes for keyword stuffing which resulted in lots of unwanted "noise".

Voice recognition (VR) users and other sighted keyboard navigators (e.g. switch users) have absolutely no access to the title attribute.

tl;dr: The title attribute should never be relied upon to convey important information. If it's important enough to be added to a page, then (ideally) it should be in clear text where everyone can see it.

#9 @Confridin
5 years ago

  • Keywords dev-feedback removed
  • Resolution set to wontfix
  • Status changed from reopened to closed

Ok, i understand that it may hurt usability.

#10 @helen
5 years ago

  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.