Last week, we talked about sharing accessible images on social media. Today, let's expand on this by learning how to share accessible code snippets.

It's common to see people share code snippets as images, especially in the tech community on Twitter. Here's how that might look:

A screenshot showing my serialize.js helper function in a code editing window.
My serialize.js helper function.

For a long code snippet, it probably doesn't make sense to use the code itself as the alt text. That's going to be a nightmare for a screen reader to announce. Instead, you might use alt text such as "A screenshot showing my serialize.js helper function in a code editing window", as I did for the screenshot above.

You should also link to a text version of your code, such as a Gist or a Pen. As with most things in the world of accessibility, this is useful to everyone, not just visually impaired people. It makes it easy for people to copy and paste your code snippet so they can try it out for themselves.