Adding Alt tags to images using image_tag in Rails

Rails makes it easy to add alt tags to images using a handy helper method.

Recently I have been running reports on an older website to see where there are quick wins to be had at improving the site.

Something that greatly benefits accessibility and has an added effect of being better for SEO is to have relevant alt text associated with your images.

If you are using Rails this is easy to implement.

You may already be familiar with using image_tag("my_image.png") which is smart enough to go and look in the assets directory for your image.

This same method accepts an alt parameter, this means that;

image_tag("icon.png", alt: "MyInc Logo")

Will generate

<img src="/assets/icon.png" alt="MyInc Logo" />

Recent posts View all

Talk CSS

FrontEnders - Web Performance

Sharing some of my thoughts on a FrontEnders meetup on the topic of Web Performance

Conferences

Tips for how to ask for time off to attend conferences

Asking for time off to attend a conference can be nerve-racking, these tips will get you closer to attending the conferences you're interested in.