Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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/
Comment | File | Size | Author |
---|---|---|---|
#31 | patch-d8-breadcrumb_0000_ie8-post.jpg | 132.44 KB | mducharme |
#31 | patch-d8-breadcrumb_0001_safari-pre.jpg | 185.67 KB | mducharme |
#31 | patch-d8-breadcrumb_0002_safari-post.jpg | 186.11 KB | mducharme |
#30 | drupal8.breadcrumb-theme.30.patch | 1.13 KB | sun |
#27 | drupal8.breadcrumb-theme.27.patch | 709 bytes | sebsebseb123 |
Comments
Comment #1
mgiffordtagging. @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.
Comment #2
tstoecklerWhat is there to do?
theme_breadcrumb() does just that, only with < ol > instead of < ul >, which in this case makes sense, IMO.
Comment #3
RedTop CreditAttribution: RedTop commentedIf 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>
:http://webaim.org/techniques/semanticstructure/
Comment #4
Everett Zufelt CreditAttribution: Everett Zufelt commentedOn first glance it does not appear that the D7 http://api.drupal.org/api/drupal/includes!theme.inc/function/theme_bread... uses a list.
Comment #5
mgiffordThis is the D8 code:
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?
Comment #6
Everett Zufelt CreditAttribution: Everett Zufelt commented@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.
Comment #7
mgifford@Everett - What are your impressions of adding the ARIA tags to add further semantics?
Comment #8
BarisW CreditAttribution: BarisW commentedI've only added the aria-labelledby attribute, as described here: http://www.uvd.co.uk/blog/accessible-breadcrumbs-using-aria/
Comment #9
Everett Zufelt CreditAttribution: Everett Zufelt commented@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.
Comment #10
BarisW CreditAttribution: BarisW commentedHi 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.
Comment #11
Everett Zufelt CreditAttribution: Everett Zufelt commentedThanks 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.
Comment #12
mgiffordJust 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.
Comment #13
sunMarked #1815356: Breadcrumb separator is a non-standard entity and not recognized by screen-readers as duplicate.
Quoting myself from over there:
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:
Objections? :)
Comment #14
BarisW CreditAttribution: BarisW commentedThe 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?
Comment #15
mgifford@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.
Comment #16
mgiffordI 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.
Comment #17
mgiffordI'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.
Comment #18
sunre #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).
Comment #19
mgiffordSo, 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.
Comment #20
mgifford#16: drupal8.breadcrumb-theme-aria.16.patch queued for re-testing.
Comment #21
mgiffordWe 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.
Comment #22
sunSure, 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).
Comment #23
sebsebseb123 CreditAttribution: sebsebseb123 commented- 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! :)
Comment #24
mparker17Issue in IE8: breadcrumb separators not showing up
Comment #25
webchickYeeaaah, 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"
Comment #26
sebsebseb123 CreditAttribution: sebsebseb123 commentedBumping status back down, since a solution needs to be worked out for IE8.
Comment #27
sebsebseb123 CreditAttribution: sebsebseb123 commentedReplaced the CSS solution with an aria role="presentation" solution.
Comment #28
mparker17Looks good in Seven, Bartik and Stark in FF16, Chrome 23 (beta), IE8 and IE9.
Comment #29
mgiffordCan we get this tested by a screen reader before marking it RTBC?
Comment #30
sunThe simple solution for IE8 is to replace :last-child with :first-child, and to use a separate selector instead of :not.
Comment #31
mducharme CreditAttribution: mducharme commentedLooks 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."
Comment #32
xjmExcellent patch. I do this in every single theme on every single site. Thanks all!
Comment #33
webchickCommitted and pushed to 8.x. Thanks!