The title attribute merely parrots the node title, i.e. title="<?php print $title ?>, which apart from being redundant (does not add additional information about the link target or context), its annoying for screen readers configured to read title attributes (gets repeated, thus is again redundant).

This issues proposes to remove the title attribute from Drupal core.

CommentFileSizeAuthor
node-title-attribute_1.patch676 bytesJeff Burnz
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Jeff Burnz’s picture

Status: Active » Needs review

I'm not sure why the test has not run, changing to needs review to see for myself if this triggers automated testing:)

geerlingguy’s picture

Please be sure to make note of this in the related issue: #382870: Update and Polish Node Template Output.

Jeff Burnz’s picture

Thank-you geerlingguy, that issue had temporarily slipped my mind.

geerlingguy’s picture

Well, since it's been more than a few days without a reply, that issue slipped into page three on my tracker!

mgifford’s picture

Issue tags: +Accessibility

Ok, I don't know who this redundant information would help. As far as I am aware this simplification would be fine.

<h2><a href="<?php print $node_url ?>" title="<?php print $title ?>"><?php print $title ?></a></h2>
Jeff Burnz’s picture

Thanks for tagging this, I seem to always forget to do that.

The patch takes what you have there (which is default) and removes the title attribute, i.e:

<h2><a href="<?php print $node_url ?>"><?php print $title ?></a></h2>
cburschka’s picture

Status: Needs review » Reviewed & tested by the community

Looks good, and fixes a real redundancy. The title attribute on a link should indicate where the link goes if that isn't clear from the anchor text - not repeat the anchor text. Seems to be RTBC too.

mgifford’s picture

Thanks for this. I did understand it, but didn't explain it all that well.

geerlingguy’s picture

Sounds good - I agree with the RTBC. Let's commit it. Otherwise, we'll roll it into #382870: Update and Polish Node Template Output.

webchick’s picture

Does someone have an "official" external resource regarding title best practices they could point to that explains why Drupal is doing this wrong? I don't disagree, it just would be nice to be able to point at that and go "Ah."

boombatower’s picture

Interestingly W3C has an example very similar to what we are talking about: http://www.w3.org/TR/REC-html40/struct/global.html#h-7.4.3 , but otherwise doesn't say anything directly.

Other resources seem to directly agree with removing it.

Not So Good Practices

* Adding the exact text in the accompanying the link (this kind of a moot point since the title attribute essentially adds no new information in this case)

http://fadtastic.net/2007/04/19/proper-use-of-alt-and-title-attributes

One good use of the title attribute is to add descriptive text to links, especially if the link text itself doesn’t clearly describe the link’s destination.

http://www.456bereastreet.com/archive/200412/the_alt_and_title_attributes/

I would agree that removing the title attribute that contains a pure duplicate makes sense, both logically and based on online agreement.

Jeff Burnz’s picture

From RNIB, a site supporting blind and partially sighted people.

Identical link text and TITLE attribute.

This is repetition for, and may be confusing to; users who have screen readers that do read aloud the TITLE attribute.

http://www.rnib.org.uk/wacblog/articles/too-much-accessibility/too-much-...

The above page is a good resource in general and explores the various issues regarding title attributes and accessibility.

webchick’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs documentation

Makes sense to me. Thanks, folks!

Committed to HEAD. Marking "needs work" until this is mentioned on the converting 6.x to 7.x themes page.

cburschka’s picture

1.) What do we need to tell theme designers - to copy this change to their own node.tpl.php files?

2.) Who can edit that page? I can only see the Revisions tab; is it locked or do I need to apply for a "doc team" role?

xmacinfo’s picture

Issue tags: +garland

Actually this modification does not need documentation. Adding or removing the title attribute in themes do not have any compatibility impact with Drupal 6 or Drupal 7.

However, we need to update the Garland theme; so it's best to keep this at "needs work" until Garland is modified as well.

LeeHunter’s picture

The Theming Guide seems a little weak in the area of accessibility. Well, actually, there doesn't seem to be anything at all. I've added an issue to the doc queue (http://drupal.org/node/462532) suggesting there should be at least one accessibility page in the best practices section (http://drupal.org/node/341707).

mgifford’s picture

webchick - I can't edit this page - http://drupal.org/node/254940

But also not sure that it needs to be there, particularly since there's been work done on the Theming Best Practices page - http://drupal.org/node/464472

LeeHunter - thanks for pointing us to the hole in the theming documentation for accessibility. It is coming along now thanks to a great start by jmburnz.

Mike

Everett Zufelt’s picture

Great patch, this is something that I noticed when I first started using druPpal, Aas some developers use the title attribute for tooltip text and some assistive technology reads this and not the linked text.

I see that this is now in head. I don't think that this really needs to be documented on http://drupal.org/node/254940 . It would be nice if Garland followed the same practice and if this was explained on the accessibility best practices page.

Is there currently an open issue to make this change to Garland?

Everett Zufelt’s picture

I have created an issue to remove the title attribute from node title for Garland http://drupal.org/node/518284

I also copied the concept from the patch for this issue and uploaded a patch for review for the Garland specific issue.

Everett Zufelt’s picture

The Garland specific patch has been commited to head and the issue marked as Fixed http://drupal.org/node/518284 .

What else needs to be completed to have this issue marked as Fixed?

Jeff Burnz’s picture

This was rolled into #382870: Update and Polish Node Template Output so best to help out there.

xmacinfo’s picture

In #13 webchick is asking for documentation. This is why it's not fixed.

However I feel that this does not require any documentation.

geerlingguy’s picture

I second the unneeded documentation... if anything, we could say "The title attribute was removed from node titles because it's redundant."

xmacinfo’s picture

Status: Needs work » Fixed

OK. Let's mark this fixed. :-)

webchick’s picture

Status: Fixed » Needs work

Er. Well assuming that Garland is not the only contributed theme that explicitly prints out the title attribute like this (and I highly doubt that's the case), the change needs to be mentioned at http://drupal.org/update/theme/6/7 (with a before/after code snippet) so that themers can make similar adjustments in their own theme. Otherwise this anti-pattern will continue to propogate, since it's what Drupal core has been doing for years.

webchick’s picture

You can also (and are encouraged to!) add it to some sort of "Theme best practices" document if such a thing exists in the handbook.

But seriously, this needs to be documented somewhere other than one of the 13K random issues in the Drupal core issue queue. :P

geerlingguy’s picture

Speaking of theming best practices, is there a doc somewhere for that? If there isn't there should be one. I know there's some sort of coding best practices, but that's not all that visible to designers/themers...

LeeHunter’s picture

Theming best practises are covered here: http://drupal.org/node/341707

Everett Zufelt’s picture

Added the following to Designing Accessibility into Themes http://drupal.org/node/506866 in the theming guide.

Do not repeat redundant information in title attributes. Using the title attribute in a link can be a good way to communicate information about the link to assistive technology users. However, if the information in your title attribute presents the same information that is in the linked text, or does not accurately describe the link then remove it or change the text in the title attribute.

Everett Zufelt’s picture

Status: Needs work » Fixed

Status: Fixed » Closed (fixed)
Issue tags: -Needs documentation, -Accessibility, -garland

Automatically closed -- issue fixed for 2 weeks with no activity.