[wp-trac] [WordPress Trac] #54079: Remove "role" attribute on HTML5 elements with a default landmark role.

WordPress Trac noreply at wordpress.org
Tue Sep 7 07:47:12 UTC 2021


#54079: Remove "role" attribute on HTML5 elements with a default landmark role.
----------------------------+----------------------------------------------
 Reporter:  costdev         |       Owner:  (none)
     Type:  enhancement     |      Status:  new
 Priority:  normal          |   Milestone:  Awaiting Review
Component:  General         |     Version:
 Severity:  normal          |  Resolution:
 Keywords:  has-patch       |     Focuses:  accessibility, coding-standards
  needs-refresh             |
----------------------------+----------------------------------------------

Comment (by costdev):

 Excellent point @mukesh27!

 Per W3C:
 > `<footer>`
 >
 > `contentinfo` when in context of the
 > `body` element. The `footer` element is
 > not a `contentinfo` landmark when it is
 > a descendant of the following HTML
 > sectioning elements:
 >
 > - `article`
 > - `aside`
 > - `main`
 > - `nav`
 > - `section`

 As "context of the body element" can mean inside any number of non-
 sectioning elements, we can't use `body > footer` as the selector.

 To avoid having a selector like this:

 {{{#!css
 *:not(article):not(aside):not(main):not(nav):not(section) > footer {
     /* Rules */
 }
 }}}

 I think we could just add a `.contentinfo` class on the relevant `footer`
 elements in this theme, and adjust the CSS selectors accordingly:

 {{{#!css
 footer.contentinfo {
     /* Rules */
 }

 footer.contentinfo a {
     /* Rules */
 }

 footer.contentinfo a:hover {
     /* Rules */
 }
 }}}

 The likelihood of a child theme or plugin having other `footer` elements
 with a `.contentinfo` class seems very low, whereas something more general
 like `.primary` or similar feels a bit risky. This way, the update
 shouldn't unintentionally affect other `footer` elements.

 However, it's possible that sites that use this theme have custom styles
 that target `footer[role="contentinfo"]`. I don't think there's anything
 we can do about that - the custom styles would need to be updated.

 What are your thoughts?

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/54079#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list