top | item 27415069

(no title)

chrisjshull | 4 years ago

For all those saying that ARIA trumps semantic elements, consider that for basic interactions semantic elements come out of the box keyboard accessible.

For example, a <button> will have default tabindex=0 and respond to spacebar key presses, but you'd have to add that yourself if you put role=button on a <div>.

In short, if there is a semantic element that matches your need, use it.

discuss

order

extra88|4 years ago

> In short, if there is a semantic element that matches your need, use it.

Yes! This is known as The First Rule of ARIA.

admax88q|4 years ago

If the browser would make the semantic elements actually look good out of the box a lot of developers would use them by default.

JoshTriplett|4 years ago

If people could agree on what "look good" means, I don't think it'd be impossible to get the major browsers to update default styles. But every site seems to have a different idea of the look they want.

I'd be curious to see a somewhat-objective look at what's actually wrong with default browser styles, separating out well-established usability and design considerations from personal preferences and branding preferences. I wouldn't be at all surprised if there are near-universal things wrong with the default styles, and those might be possible to change if they can be separated out.

robin_reala|4 years ago

Who cares about looking good, when we’re talking about working good?

Of course, it’s worth putting the effort in to both looking good and working good, but if we’re going to pick one, we should go for the second.

shadowofneptune|4 years ago

It would be equal effort to restyle something done with ARIA compared to a semantic element, yes?

pjc50|4 years ago

Isn't that an extremely moving target? What looks good is very subject to changes of fashion.

Your comment below about being difficult to style is more to the point.

loloquwowndueo|4 years ago

A div looks like nothing by default. It’s probably about the same amount of effort to make a button look good.

anoncake|4 years ago

Unfortunately, Firefox recently actually stopped making semantic elements look native (=good).

austincheney|4 years ago

The one exception for me are forms. In that case I would rather use a div or section tag with role=“form”. I have seen less experienced developers do weird things with form tags and submit event and form tags have unique behaviors associated and requirements.

inopinatus|4 years ago

When a form requires JS to be submitted, there’s a high probably that I abandon that website instead. My expectations of working plain HTML are never higher than with regard to forms. By all means, progressively enhance, but don’t be tempted by the hubris of claiming to know better than the user-agent how the user-agent should work. It’s not just rude, it’s a slippery slope towards systematic incompatibility, weirder bugs than the ones you were afraid of, and security holes.

Vinnl|4 years ago

Does that still allow you to press "Enter" in an input field to submit the form, or do you have to build your own kludge to replicate that? If so, that sounds like that would invite only more weird things...

extra88|4 years ago

That doesn't sound worse than not naming the inputs or coding the buttons for keyboard interaction, things inexperienced developers will do if they're not educated in the basics of semantic HTML (even those who do use inputs too often neglect to associate a <label> where they're called for).

brailsafe|4 years ago

I've never heard of this. Could you elaborate on why you'd not use an actual form element?