The label of a Term reference field is enclosed in a h3
element, while other fields like List, Text etc. use a div
element.
In many situations, this will create a false outline for the document.
Example:
A node "My cat" has three fields (displayed in this order): Name (Text field), Tags (Term reference), Description (Long text).
The document outline would be:
- (
h1
missing)h2
: Main menuh2
: You are here
h1
: My cat- (
h2
missing)h3
: Tags
- (
The "Description" (Long text) would be in the scope of the headline "Tags", which would be not correct, of course.
Apart from the semantic problem, this is a problem for accessibility, too: some screen-reader users use a document outline to jump to sections they are interested in. Because of the Term reference label being a heading (while all other labels not), these users might miss content that comes after that heading (like the Description in this example), when they are not interested in "Tags".
I can think of two possible solutions: use a heading for every field label OR don't use a heading for any field label.
Side effect of the Term reference label being an exceptional case: the field labels are inconsistently styled, all other labels are bolder and slightly bigger.
See also: #1169216: Unwanted <h3> in field label
Comment | File | Size | Author |
---|---|---|---|
#66 | interdiff_65-66.txt | 467 bytes | pooja saraah |
#66 | 1768732-66.patch | 1.72 KB | pooja saraah |
#65 | reroll_diff_42-65.txt | 1.78 KB | ravi.shankar |
#65 | 1768732-65.patch | 1.68 KB | ravi.shankar |
#42 | wrong_document_outline-1768732-42.patch | 1.74 KB | LewisNyman |
Comments
Comment #1
Everett Zufelt CreditAttribution: Everett Zufelt commentedThis is a bit of a difficult problem, but thanks for bringing it up. The problem is:
- we need to render headings for some render components
- we do not know where in the document hierarchy these components will appear
We might render a list with a heading, and it might be used in a sidebar block, or the footer, or in the main content of a page under another heading.
I don't think that there will be a good solution to this until we (the developer community) begins to better understand and implement HTML5 sectioning elements, which will help adjust the document outline. Of course, these also need to have better support by user agents, including assistive technology.
Comment #2
David_Rothstein CreditAttribution: David_Rothstein commentedRelated issue: #1218640: Bartik displays all taxonomy term fields in a smaller font than other fields
Comment #3
mgiffordCan we get some outlines provided from actual sites to compare?
http://gsnedders.html5.org/outliner/
http://code.google.com/p/h5o/
How do we get the "better understand and implement HTML5 sectioning elements" that Everett's called for.
Comment #4
dddave CreditAttribution: dddave commentedComment #5
mgiffordActually, shouldn't this be fixed in D8 and then brought back?
Comment #6
freelylw CreditAttribution: freelylw commentedmy god, this issue still there for 3 years already!
Comment #7
mgifford@freelylw - would love it if you could submit a patch. It's also not 3 years. It isn't 2015 yet.
Comment #8
freelylw CreditAttribution: freelylw commented@mgifford sorry I don't know how to code, love to do this if I can. I just start to use D7 and noticed this problem
Comment #9
mgiffordI wrote a longer reply, but lost it.
This probably is hard as described in #1. I don't know any CMS that has resolved it. Closest approach might be:
https://github.com/ThePacielloGroup/html5-h
That is something we could work towards for Drupal 9.
Some related links:
http://accessibleculture.org/articles/2011/10/jaws-ie-and-headings-in-ht...
http://www.smashingmagazine.com/2013/01/18/the-importance-of-sections/
It's never too late to learn to code. Alternately to reach out to the AT vendors and get consensus from them on how to deal with this.
Comment #10
mgiffordComment #11
catchComment #12
emma.mariaFrom feedback in #1218640: Bartik displays all taxonomy term fields in a smaller font than other fields in August it has been explained that the taxonomy field needs to look deliberately different to the other headings.
A quote for Jen...
So I think a h3 element was just chosen to make the styling look visually different, as h3s print at a smaller in size. I don't see why we can't change term reference headings to print with the same markup as the other fields but with a class that can add particular styles. Seven is dealing with the styling of headings and accessibilty etc here #2028053: Add typographic styles, components, and utility classes.
But looking at the recent status changes this issue seems to have been postponed to 8.1.x-dev so I will set it as so. Feel free to open this up again or create another issue to change the term reference markup.
Comment #13
mgiffordIt needs to be a heading for accessibility. A heading (H1-H6) is needed semantically before a list (UL or OL) for screen reader users.
Comment #14
David_Rothstein CreditAttribution: David_Rothstein commentedSince this is (a) an accessibility issue, and (b) can perhaps be fixed with only a markup change - aren't those two independent reasons why this can still be an 8.0.x issue?
So Everett's comment in #1:
That's basically the way to solve this, right? You can use
<section>
or similar to wrap the list of terms, and then inside that it doesn't matter what level heading you use, right? - i.e.<h1>
is allowed. And since Drupal 8 already uses<section>
elsewhere I assume it's supported enough by screen readers at this point that it's OK to use?....I'm also adding the backport tag here since it was mentioned above that it would be good to fix this in Drupal 7. We can't assume HTML5 there so I'm not sure what the solution would be, but we should at least see if there's something we can do.
Comment #15
emma.mariaI agree with @David_Rothstein.
Using a HTML5 section means it's contents can have it's own heading hierachy. Read here for a good example... https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Sections_and_Out....
https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Sections_and_Out... explains Sections.
Patch please :)
Comment #16
Jeff Burnz CreditAttribution: Jeff Burnz commentedThis is incorrect: http://www.w3.org/html/wg/drafts/html/master/sections.html#outlines
I think what you mean however is that screen readers can navigate the page using headings, if so, then yes, this is correct.
This is a CSS issue.
I can only think of one out of the box - in forum posts the tags field is right at the top. However, this is in no way the fault of the h3 on the term list, the problem is caused by not using a new heading to introduce the long text. OK, so we know this, the proposal here is to use section element to fix this issue, however it will not fix the issue because no user agent recognises section element as a sectioning element.
Mike is right, we must use headings on lists, and lets be frank, a heading can appear anywhere in the long text itself, thus branching the outline.
I think the bigger question here is this - is this actually a real world issue? IMO no, its not really an issue. The only possible issue I can think of is for accessibility and headings for navigation, however we are merely assuming this might be an issue, however I do not see screenreader users pointing this out as a real problem, even after many years of us doing this.
At the end of the day each author needs to take particular care to structure documents with headings, personally I think the forum structure is flawed, but html5 is not going to save us here. The inherent flaw is sticking an h3 in the middle of the document flow and not having an h2 directly after the tags to introduce the long text.
So, yes, we could use a section element, but it will only make us feel better, it does not fix the issue, despite what some outlining tool might indicate.
Bottom line is section/sectioning elements and html5 outlining is a fiction, it only exits in specifications, but it looks like user agents have near to zero interest in actually implementing it.
Comment #17
Jeff Burnz CreditAttribution: Jeff Burnz commentedGood gracious, I just looked at the Forum content type and now notice the entire comment form is above the content, in this case we have bigger problems for forum nodes.
And yes, its actually meant to be like this, see: core.entity_view_display.node.forum.default.yml
Update: this issue will fix the forum node comment field issue afaict judging by the current patch: #2106243: Use yml files to create the forum module's comment and taxonomy term fields
Comment #18
LewisNymanSo as Emma mentioned in #12 Seven deals with this problem by adding
header-x
classes that allow you to choose a different header style to the html element. So we can have the best of both worlds. #2028053: Add typographic styles, components, and utility classesI imagine the mark up would look something like:
<h2 class="header-c">Tags</h2>
We should implement these classes after #2375673: Split Bartik's CSS into SMACSS style components has landed
Comment #19
Jeff Burnz CreditAttribution: Jeff Burnz commentedLewis, I do this like Bootstrap does, I use small as a modifier also: e.g.:
Yes, they can be very useful.
Comment #20
emma.mariaWe will be working on the fix for this issue plus adding classes for all of the other heading styles in this issue... #2400233: Add reusable heading classes to Bartik.
Postponing this issue here for now.
Comment #21
mgiffordOk, that's fixed now.
Comment #22
mherchelPatch attached with before and after pics (should be no visual difference).
Before:
After:
Comment #23
mherchelComment #24
emma.mariaHey @mherchel. Thanks for the patch! It's almost there, we just need to implement the work @LewisNyman said in #18.
We need to have the tags title print as a h2 and then apply the h3 styles to it using the heading-x classes in the CSS.
The tags need to intentionally print "as h3s" purely for the styling, but in the markup they need to be h2 elements.
Comment #25
mherchelChanged divs to h2s
Comment #26
Jeff Burnz CreditAttribution: Jeff Burnz commentedProbably should add a screenshot or two (before, after). Otherwise this would be RTBC.
Comment #27
emma.mariaThe patch is technically correct thank you so much @mherchel! But due to other (bad) CSS in the theme that we haven't refactored yet the solution does not kick in as we like. The heading styles do not work because of far far too much overspecifity from other css. We want to fix this in Bartik with reusable classes, no multi level selectors, no selectors containing raw html elements and we are just not that far enough with the taxonomy tags section.
See screenshots.
I am postponing this issue until we clean up the related CSS. The h2 having just the class heading-c is the perfect ideal way to go!
Comment #28
mgifford@emma.maria - what is this postponed on?
Comment #29
David_Rothstein CreditAttribution: David_Rothstein commentedI don't see how switching from a hardcoded H3 to a hardcoded H2 helps... doesn't it actually make things worse?
The original problem here was just about a missing heading level on node pages (i.e. a jump from H1 to H3) which was relatively minor, I think.
But if it's switched to an H2, then on pages which display a list of node teasers (like a view, e.g. the default front page), things get a lot worse.
Before patch:
After patch:
Seems like it would be a lot worse to me; now it's no longer obvious that the tags are associated with each node - rather they appear like nodes of their own.
Maybe there's a way to do this so H2 is used only on the full page node view (at node/X) but H3 is still used everywhere else?
Comment #30
David_Rothstein CreditAttribution: David_Rothstein commentedDo you know why? Is it that screen readers haven't gotten around to it yet, or they're deliberately not going to do it?
Given that this is part of the HTML5 standard it seems like the best general solution available to Drupal is to start using it in these situations and then hope user agents will respect the standard... but I guess it would be pointless if they're never going to for some reason.
Comment #31
no2e CreditAttribution: no2e commented@David_Rothstein (#29):
No, the original problem was not about a missing heading level. The problem was that the label of the Term reference field was the only field label that had a heading.
To make the outline useful (and this is not only about HTML5’s outlining algorithm, but also for various user agents that use the heading structure to navigate the document) either every or no field label should use a heading (by default).
Depending on the node layout, it can make sense to have a heading only for some field labels, but this always depends on the particular content meaning and can not be a default choice made by Drupal.
Comment #32
David_Rothstein CreditAttribution: David_Rothstein commentedTrue, although this isn't a problem with the default node layout provided by core... and on some level it's the responsibility of a site builder or install profile to make sure they build things in an accessible way (although in practice I can see that very few people will ever think about this specific issue).
So this is really a conflict between two accessibility goals?
As far as I understand, HTML5
<section>
elements are the only real solution to this problem too (since they allow you to show where the "end" of the section covered by the heading is), so it comes right back to the question in my previous comment :)Comment #33
no2e CreditAttribution: no2e commentedHuh, why is that? Markup like this is totally fine according to HTML5 and WCAG 2.0:
There might be lists that need a heading, but this is not because they are lists, but because of their content/context (and this does apply to any field type, not only lists).
Yes, using
section
elements explicitly (which is what the HTML5 Rec encourages authors to do) would solve this problem.If used for all fields, it’s essentially the same solution as using a heading for every field label, but with the added benefit that an actual heading now is no longer required: the outline stays the same, no matter if a heading element gets used or not. However, creating a section by default for every field is not appropriate.
So it should only be used for those fields where it’s known that a separate section/heading is appropriate in the typical case. But I can’t think of a default field where this would be the case.
In my opinion, the better solution is not to use any heading element (
h1
-h6
) or sectioning content element (section
,article
,aside
,nav
) in the default field markup: this guarantees that the document outline will never be incorrect (everything is in scope of the headings intentionally provided by the author).Comment #34
LewisNymanIn my experience, trying to solve the overall architectural issues in a bug report usually means that neither get fixed, or not for a very long time at least. I would really recommend we fix the initial bug reported in this issue and open a follow up to discuss changing our HTML policy to
<section><h1>
- I can't see that happening before 8.1 thoughComment #35
Jeff Burnz CreditAttribution: Jeff Burnz commented#30 I don't know why, I do know Jaws have tried it but discontinued development. Its not just screen readers though, no user agents implement this afaict. I tend to think everyone is focused much more on ARIA, RDFa etc whereas relying on outlines is very difficult because the specs are ambiguous (therefor implementations vary too much to be reliable).
With regards to the design change, lets just make sure it works with the label inline, that was the original reason why the label/heading font size matches the tax term size.
Comment #36
Jeff Burnz CreditAttribution: Jeff Burnz commentedFYI here is the original discussion from regarding menus and headings (the tax terms are basically a menu) #364219: Navigation menus should be preceded by headings of the appropriate level (usually <h2>)., I can't find the issue for tax terms, however that is the root issue that kicked it all off in Drupal, I would also add that this had been very successful in terms of improving accessibility, its basically been in the field for 6 years and has proven very useful and robust. We absolutely should not change this unless better technology comes along and has broad support and is widely used.
Comment #37
mgifford@no2e Screen reader users navigate by the headings. Without a heading they will just skip over a list of links and not get a sense of the structure of the page. An example from the W3C is:
http://www.w3.org/TR/2008/WD-WCAG20-TECHS-20080430/H42.html#H42-ex1
http://www.w3.org/TR/2008/WD-WCAG20-TECHS-20080430/H69.html#H69-ex2
As @Jeff Burnz said, this is also something we've tried to implement consistently in the interface since D7. It would be good if we could continue with that.
@LewisNyman agree with setting up a new issue to discuss broader policy issues for 8.1.
By adding tags to an article and viewing them here, I expect to see this problem.
node/1
/taxonomy/term/2
The outliner here https://gsnedders.html5.org/outliner/ shows the Comments under the Taxonomy, but that's a bit of a mess. That doesn't make sense to me as the taxonomy is an H3, but the comments are an H2.
There's a limit to how perfect we can make this and it's unclear to me how critical the hierarchy is in most cases. Absolutely it's better if it is nested correctly...
Comment #38
emma.mariaWhat is the most logical solution for this issue? We need clear instructions to move this issue forward, otherwise it is just going to sit here.
Also if the solution turns out to be we just to do nothing, I can close the issue.
Comment #39
LewisNymanChange the tags h3 -> h2. At least it's not broken out of the box.
Comment #40
mgiffordOk, this is essentially a re-roll of #25. Except that core/themes/bartik/templates/field--taxonomy-term-reference.html.twig no longer exists & there was no explanation as to why
'heading-c',
was added.'heading-c',Lets see if this gets us closer.
Comment #41
David_Rothstein CreditAttribution: David_Rothstein as a volunteer commentedI didn't test the latest patch, but doesn't switching from a hardcoded h3 to a hardcoded h2 make accessibility worse rather than better? (We discussed that earlier; see my comment in #29.)
Comment #42
LewisNyman@David_Rothstein Ah yes you're right, sorry for my drive-by solutioneering :D We'd just be replacing a problem with another problem.
I've written a patch that passes the view mode into the twig template. The template assumes if you're not using 'full' then it's probably a listing. Pretty basic but I guess someone would use display suite to keep complex logic sane.
Comment #43
emma.mariaLooking at the patch in #42 I feel like Bartik is adding even more to an already overengineered specific field in Core. I am tempted to take out the heading tag altogether from the tags field template.
No other field label has a heading and no other theme in Core adds the heading. Also the heading field is not being styled different to other fields based on the h3. I can't see a reason to keep the h3.
*winces incase of backlash :-)*
Comment #44
no2e CreditAttribution: no2e commented+1 @emma.maria.
This is what I suggested in the initial post, too:
And in my opinion it makes more sense to use the "no heading" case, as I’m pretty sure that more sites use fields in a way that doesn’t warrant headings or sectioning content elements.
Comment #45
mgiffordHeadings are important for navigation. It is more complex, but it is critical for blind and low vision users who use headings to provide context for the page.
There really isn't that much logic that is being added to provide this, and it makes Drupal more consistent.
Comment #46
mgiffordIn looking at this issue I decided to use the outline function in the WAVE Toolbar. It was there that I noticed that there is a difference in the title when you're logged in and logged out.
Logged in it looks like this (from the page.html.twig file):
Logged out it looks like this (from the node.html.twig file):
This should be a new issue, but really can't see what the headings would change between node.html.twig & page.html.twig
Anyways, logged after creating a page with a taxonomy, the hierarchy is:
Heading level 1: Trees
Heading level 2: Primary tabs
Heading level 3: Tags
Comment #47
opdaviesI feel that for consistency, the scope of this issue should be widened to affect all instances of entity reference fields, or potentially all fields.
I also propose that the resulting style amendments be dealt with in a separate issue, and this issue focus on applying the correct semantic tag and therefore resolving the original accessibility problem.
Comment #48
Jeff Burnz CreditAttribution: Jeff Burnz commented#47 yes for entity reference fields because right now Bartik is broken - see #1847596: Remove Taxonomy term reference field in favor of Entity reference, the only consistent fix here is to a) remove Bartiks template override (and in so doing reduce accessibility) OR b) "implement a new theme hook suggestion that includes the target entity type for entity reference fields" SEE https://www.drupal.org/node/1847596#comment-9813999, and convert Bartik to use this new template suggestion instead of the current field--node--field-tags.
Comment #49
mgiffordThink we're going to need to move this to 8.1...
Comment #54
Ivan Berezhnov CreditAttribution: Ivan Berezhnov as a volunteer and at Drupal Ukraine Community for Levi9 commentedComment #63
larowlanI agree with @emma.maria in #43 - bartik theme should not have a template that only applies to the standard profile. That template should be in the standard profile if it relates to its content model.
I think at this point, we might be best to either close this issue and start a new one to just remove that template or decide to mark this as closed won't fix given Bartik is now deprecated.
Comment #65
ravi.shankar CreditAttribution: ravi.shankar at OpenSense Labs commentedAdded reroll of patch #42 on Drupal 9.5.x.
Comment #66
pooja saraah CreditAttribution: pooja saraah at Srijan | A Material+ Company for Drupal India Association commentedFixed failed commands against #65
Attached interdiff
Comment #67
pooja saraah CreditAttribution: pooja saraah at Srijan | A Material+ Company for Drupal India Association commentedComment #69
smustgrave CreditAttribution: smustgrave at Mobomo commentedThis appears to be specific. to bartik and since bartik was removed in D10 going to move to contrib module