CSS clip deprecated - .visually-hidden needs an update?

Created on 17 October 2016, over 7 years ago
Updated 20 June 2023, 12 months ago

I was just forwarded this article - http://hugogiraudel.com/2016/10/13/css-hide-and-seek/

I haven't tested this, but essentially she's recommending:

.visually-hidden {
  border: 0 !important;
  clip: rect(1px, 1px, 1px, 1px) !important;
  clip-path: inset(50%) !important;
  height: 1px !important;
  overflow: hidden !important;
  padding: 0 !important;
  position: absolute !important;
  width: 1px !important;
  white-space: nowrap !important;
}
.visually-hidden.focusable:active,
.visually-hidden.focusable:focus {
  clip-path: none !important;
  height: auto !important;
  overflow: visible !important;
  position: static !important;
  width: auto !important;
  white-space: normal !important;
}

We'd need to keep clip (even though it is depreciated) and add clip-path as the latter's support isn't all that great thus far.

Would love feedback on this.

🌱 Plan
Status

Postponed: needs info

Version

11.0 πŸ”₯

Component
SystemΒ  β†’

Last updated 1 day ago

No maintainer
Created by

πŸ‡¨πŸ‡¦Canada mgifford Ottawa, Ontario

Live updates comments and jobs are added and updated live.
  • CSS

    It involves the content or handling of Cascading Style Sheets.

  • Accessibility

    It affects the ability of people with disabilities or special needs (such as blindness or color-blindness) to use Drupal.

  • Needs issue summary update

    Issue summaries save everyone time if they are kept up-to-date. See Update issue summary task instructions.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡¨πŸ‡¦Canada mgifford Ottawa, Ontario

    Seems like there is still partial support across the board https://caniuse.com/css-clip-path

    From HTML5 Boilerplate
    https://github.com/h5bp/main.css/blob/main/src/_helpers.css

    /*
     * Hide visually and from screen readers
     */
    
    .hidden,
    [hidden] {
      display: none !important;
    }
    
    /*
     * Hide only visually, but have it available for screen readers:
     * https://snook.ca/archives/html_and_css/hiding-content-for-accessibility
     *
     * 1. For long content, line feeds are not interpreted as spaces and small width
     *    causes content to wrap 1 word per line:
     *    https://medium.com/@jessebeach/beware-smushed-off-screen-accessible-text-5952a4c2cbfe
     */
    
    .visually-hidden {
      border: 0;
      clip: rect(0, 0, 0, 0);
      height: 1px;
      margin: -1px;
      overflow: hidden;
      padding: 0;
      position: absolute;
      white-space: nowrap;
      width: 1px;
      /* 1 */
    }
    
    /*
     * Extends the .visually-hidden class to allow the element
     * to be focusable when navigated to via the keyboard:
     * https://www.drupal.org/node/897638
     */
    
    .visually-hidden.focusable:active,
    .visually-hidden.focusable:focus {
      clip: auto;
      height: auto;
      margin: 0;
      overflow: visible;
      position: static;
      white-space: inherit;
      width: auto;
    }
    
    /*
     * Hide visually and from screen readers, but maintain layout
     */
    
    .invisible {
      visibility: hidden;
    }
  • πŸ‡¨πŸ‡¦Canada mgifford Ottawa, Ontario

    Adding another example from the community - https://blog.logrocket.com/design-accessibility-css-visually-hidden-class/

    Still no need to update as long as browser support clip[] at this point.

Production build 0.69.0 2024