Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS Framework Basics Prototyping with Bootstrap Building a Header, Navigation, and Jumbotron Component

How important it's using the role attribute in an element, when you using bootstrap ?

In bootstrap documentation, they used an extra attribute (role) in most of their elements like. button, menu. Is it important to declare the role attribute in every element ?

1 Answer

Tim Makin
Tim Makin
17,261 Points

Hi,

From what I understand the additional role attributes are there to help improve accessibility for people using screen readers. The attributes specified, e.g. "menu" and "button" are ARIA roles which provide extra information about the semantic meaning of a HTML element to screen readers.

Some elements don't need a role attribute as the default semantics are already implemented by browsers while others need to be declared. You can read more about the various ARIA roles at the W3 (http://www.w3.org/TR/aria-in-html/).

So in short you don't need to include role attributes for every element and if you didn't include any at all your code would still work fine but you should include them where necessary to help make you code as accessible as possible.

Someone can probably answer in much better detail but hopefully that make give you some hints to get started.