You are here


Drupal 8 Programmatic Alternate Text

Having alt text on your images is a very good thing for accessibility, and a requirement for a lot of websites in order to comply with WCAG standards for ADA compliance. However, people are not very good at remembering to add alt text or don't think they have the time to craft good alt text. So, what happens is alt gets ignored or bogus content gets put into the field. As a developer I want to help these people do the right thing and, if I can, prevent them from having to do repeitive work.

Adding HTML to a menu item in Drupal 8

In a previous blog post, I added a custom class to a menu item so we could show that a menu item was unpublished. This blog post builds on the code from that blog post.

In addition to showing sighted users when a menu item is unpublished, we also need to show it to screen readers. We figured the best solution is to add some text to the link and wrap it in a <span> visible only to screen readers. So, I did the following after adding the class for sighted users:

Adding a Custom CSS Class to Unpublished Menu Items in Drupal 8

We had a requirement to indicate weather a menu item was unpublished when a user who has access to unpublished content was logged in. Drupal will not display the menu item if the user doesn't have access, but if the user does have access, it will display the menu item like normal. We needed to make it clear to the user that the menu item is representing something unpublished and will not be shown to anonymous visitors. To do this we wanted to put a dashed border around the menu item.


Subscribe to Blog