Bringing issue forward from #526674: theme_breadcrumb() lacks semantic markup to define the purpose / role of the list of links

To quote @RedTop:

The current output results in a warning when validating against WCAG 2.0 AAA, recommending the breadcrumb to be output as a list.

Solution

<?php
$output .= '<div class="breadcrumb">' . '<ul><li>' . implode('</li><li> » ', $breadcrumb) . '</li></ul>' . '</div>';
?>

Found here:
http://www.otakunozoku.com/php-imploded-wrap/

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mgifford’s picture

Issue tags: +Accessibility

tagging. @RedTop would be good to know which file you wanted to apply this to. Also, aside from the fact that it uses implode(), I don't see what else you got from your example. There are others like this right on the main PHP site.

tstoeckler’s picture

Status: Active » Postponed (maintainer needs more info)

What is there to do?
theme_breadcrumb() does just that, only with < ol > instead of < ul >, which in this case makes sense, IMO.

RedTop’s picture

If this is already applied to D8 than great. WCAG AAA requires navigation elements to be put in a list. Drupal 7 does not output the breadcrumb as a list so I had to override theme_breadcrumb() to do the above.

You are right, it should be <ol> instead of <ul> :

HTML lists - <ul>, <ol>, and <dl> - also convey a hierarchical content structure. Each of these has rules regarding their use as well. Unordered lists should be used when there is no order of sequence or importance. Ordered lists suggest a progression or sequence. Definition lists should be used explicitly for presenting a structure for definitions.

http://webaim.org/techniques/semanticstructure/

Everett Zufelt’s picture

Status: Postponed (maintainer needs more info) » Active

On first glance it does not appear that the D7 http://api.drupal.org/api/drupal/includes!theme.inc/function/theme_bread... uses a list.

mgifford’s picture

This is the D8 code:

    $output .= '<h2 class="element-invisible">' . t('You are here') . '</h2>';
    $output .= '<ol><li>' . implode(' » </li><li>', $breadcrumb) . '</li></ol>';
    $output .= '</nav>';

There's no chance of this getting back-ported to D7 as it's a markup issue. So looks like we can probably close this issue.

As far as best practices go, would it be a good idea to insert WAI-ARIA's aria-labelledby and role="navigation" here?

Everett Zufelt’s picture

@mike

yup, you're right. Was too early in the morning. Unless any core theme is overridding this then I'd say closed works as designed.

mgifford’s picture

@Everett - What are your impressions of adding the ARIA tags to add further semantics?

BarisW’s picture

Status: Active » Needs review
FileSize
1.36 KB

I've only added the aria-labelledby attribute, as described here: http://www.uvd.co.uk/blog/accessible-breadcrumbs-using-aria/

Everett Zufelt’s picture

@BarisW

Thanks for trying this out. Have you tested w/ any screen-readers (NVDA/JAWS/VoiceOver), is the label read when navigating to the ul? I wonder if it is truely necessary, since the heading is directly before the UL in the DOM. Not a lot of screen-reader users navigate by list.

BarisW’s picture

Hi Everett,

I tried with VoiceOver and there is a difference.

Without the patch you hear 'Heading level 2, You are here' followed by 'List, 3 items'.
With the patch you hear 'Heading level 2, You are here' followed by 'List, You are here, 3 items'.

I haven't test the other screen-readers though.

Everett Zufelt’s picture

Thanks for testing. I wonder if this is what we want to have happen.

If we do this, we should apply it consistently to lists preceeded by headings. Perhaps it would be a good idea to close this issue, and to open a more generic issue to encourage a discussion around this concept and to make sure that it is consistently applied in Core.

mgifford’s picture

Just trying to clarify things here. So we're proposing adding an ID for every list with element-invisible H2 that is then linked to from the UL or OL with a aria-labelledby associated with that ID.

We're not proposing using the NAV tag generally for lists of links or the CSS2 :after pseudo attribute to place the visual '>' for the breadcrumbs.

Although until Modernizr and/or Selectivizr gets into core #1252178: Add Modernizr to core we're going to have difficulty with some of the older browsers.

We'd want to expand this to also include some of his ideas about pagination:
https://mikewest.org/2010/02/an-accessible-pagination-pattern

We could certainly postpone this one and set up a new issue.

sun’s picture

Marked #1815356: Breadcrumb separator is a non-standard entity and not recognized by screen-readers as duplicate.

Quoting myself from over there:

I don't quite understand why the ordered list is not sufficient?

If the » character is not read/understood by screen-readers, only the OL remains, which has a leading heading of "You are here:" — 1. Home - 2. Foo - 3. Bar... would be helpful to understand what's wrong with that?

If possible, then I'd rather remove the » separator entirely from the HTML markup and output it via CSS instead:

.breadcrumb li:not(:last-child):after {
  content: ' » ';
}

Regarding the aria-labelledby and injecting HTML IDs everywhere, that's an absolute no-go.

Instead, aria-label suggests that we should be able to drop the entire heading (which is only output for screen-readers), and instead provide the label directly for the OL:

<ol aria-label="You are here">
<li><a href="/">Home</a></li>
<li>...</li>
</ol>

Objections? :)

BarisW’s picture

The patch works fine. Great idea to use the aria-label attribute.

A great thing about this solution is that it solves the problem with breadcrumbs placed above the page title and introducing an error on the heading order (H2 placed above a H1).

However, when I tried the output of VoiceOver, the heading was not read out anymore (instead of the H2). Not sure if this is just bad configuration of my VoiceOver, maybe Everett can answer if this is correct?

mgifford’s picture

Title: Bring theme_breadcrumb() up to WCAG 2.0 AAA » Bring theme_breadcrumb() up to WCAG 2.0 AA

@sun regarding dropping the invisible H2, since we need to be somewhat backward compatible (along with what we're doing with regular browsers), what was discussed at the last accessibility sprint was that we'd need to keep the H2's as they are still the most prominent way that screen reader users navigate within a web page. I do think in D9 we'll be able to remove all of the invisible H2's, from Drupal. Just not yet.

Like the idea of moving the » up to CSS as a solution. much easier than having to define an invisible next value.

mgifford’s picture

I checked in with Paul Jackson who is behind the Government of Canada's Web Experience Toolkit and he agrees that it's important to keep the heading. With the heading the breadcrumb stays within the HTML5 outline:

Using their example with the html5 outliner it's good to see that the order is given much less importance.

http://wet-boew.github.com/wet-boew/demos/index-eng.html
http://gsnedders.html5.org/outliner/process.py?url=http%3A%2F%2Fwet-boew...

There are also some problems at this stage with the AT support for all ARIA functionality. It's coming but not consolidated yet. Have to be careful what to apply & when.

mgifford’s picture

I'm actually now thinking that the text "You are here" should be replaced with "Breadcrumb trail" as the latter is more consistent with other headings on the page. As a screen reader user is navigating the page they'll jump through the outline and I do think that what we've done in D7 might be a big confusing, where what's been used by the Government of Canada is at least consistent with the type of other headings that are being presented.

sun’s picture

re #17: The problem with that is that "Breadcrumb trail" is not really a term that exists. Only web designers/developers are able to understand what it means. It's not really translatable either — most often it's replaced with the synonymous term "hierarchy". (Though to not leave you with wrong facts, "breadcrumb" is translatable and a known dictionary word, but means... well, something completely different to innocent humans. It's like pointing at a car and saying "tomatoes.")

The idea of using "You are here" is I think derived from web sites that actually output a label/heading before the breadcrumb (visible for sighted users).

mgifford’s picture

So, I think this first came up with - #526674: theme_breadcrumb() lacks semantic markup to define the purpose / role of the list of links

The links for that come from WebAIM & the W3C which haven't really been updated in a while. WebAIM is using You are Here.

Interesting point about web terms vs human terms.

Paul Jackson's points in our discussion are that "You are here":
- Makes no sense in a document outline (e.g., a table of contents). Just because it worked as a label doesn't make it a good section heading.
- For example in WET, other headings are "Site menu", "Secondary menu", "Footer" so "You are here" really seems inconsistent.
- Headings that would be more consistent with "You are here" are "Main places you can go" and "Other places you can go".
- Switching to a "You are here" ignores historical context.

While "Breadcrumb trail":
- seems to be common term. Would be odd to see "You are here" in HTML5 outline where other headings identify a section.
- originates from the popular German story of Hansel and Gretel published in 1812 and not Web developers.
- It is a common term that has existed throughout the ages and was repurposed for the Web.
- In French Fil d'Ariane is tied to Greek Mythology.
- Same for Spanish where hilo de Ariadna is tied to the Labrynth in Greek Mythology.
- Usability testing on the whole outline rather than the breadcrumb section may make it easier for people to understand

The main disadvantage I see of moving to "Breadcrumb trail" is translation into the 100+ translation groups that Drupal has and that will need to work through the existing Locale files.

mgifford’s picture

mgifford’s picture

Issue tags: +a11ySprint

We don't have to change the title of the heading here. We can do that elsewhere if we like.

I would like to break out the breadcrumbs though so that they are structured correctly like in the patch above.

sun’s picture

Sure, I'd also love to move forward here. :) Let's move the label/heading change into a separate issue, good idea.

If you're fine with this patch, then I think we're ready to go. This is the same as #16, just without a bogus extra blank line in the CSS (the new style is added to the existing breadcrumb styles).

sebsebseb123’s picture

Status: Needs review » Reviewed & tested by the community

- Installed Drupal 8.
- Applied patch #22.
- Enabled screen reader to browse through links on Safari.
- Breadcrumbs are being read properly, without the arrow.
- Checked HTML/CSS to verify the arrows are not being rendered in the HTML, rather they're being rendered via CSS.
- Tested in "Seven" and "Garland" themes.
- Works great! :)

mparker17’s picture

Issue in IE8: breadcrumb separators not showing up

webchick’s picture

Status: Reviewed & tested by the community » Needs work

Yeeaaah, I don't think that's gonna fly. :\ It's fine for IE8 to degrade visually, but that basically makes the breadcrumb unusable. :(

Basically, it turns "Administer >> Foo bar >> Baz" to "AdministerFoo barBaz"

sebsebseb123’s picture

Issue tags: -a11ySprint

Bumping status back down, since a solution needs to be worked out for IE8.

sebsebseb123’s picture

Status: Needs work » Needs review
FileSize
709 bytes

Replaced the CSS solution with an aria role="presentation" solution.

mparker17’s picture

Looks good in Seven, Bartik and Stark in FF16, Chrome 23 (beta), IE8 and IE9.

mgifford’s picture

Can we get this tested by a screen reader before marking it RTBC?

sun’s picture

The simple solution for IE8 is to replace :last-child with :first-child, and to use a separate selector instead of :not.

mducharme’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
186.11 KB
185.67 KB
132.44 KB

Looks good to me. Attached screenshots including an ie8 cap. Voiceover in Safari reads the same pre and post patch: "You are here. Home. Forums. General Discussion."

xjm’s picture

Excellent patch. I do this in every single theme on every single site. Thanks all!

webchick’s picture

Category: feature » task
Status: Reviewed & tested by the community » Fixed

Committed and pushed to 8.x. Thanks!

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