Role in html tags

I see that html validator gives me warning on using the roles attribute in my html tag. As in:

The complementary role is unnecessary for element aside.

And an error in;

Error: Bad value search for attribute role on element form.
From line 291, column 63; to line 291, column 158
t_search">:leftwards_arrow_with_hook:

So are roles no longer used or needed?
thx

The <aside> tag already defines its “role” on its own - i.e. an aside - so giving it a role is redundant.
That is, it is not semantically neutral.

But there is still a use for the role attribute

https://www.w3.org/TR/role-attribute/#s_role_module_attributes

Although the role attribute may be used to add semantics to an element, authors SHOULD use elements with inherent semantics, such as p, rather than layering semantics on semantically neutral elements, such as div role=“paragraph”.

2 Likes

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.