{"id":385769,"date":"2025-11-06T08:57:49","date_gmt":"2025-11-06T15:57:49","guid":{"rendered":"https:\/\/css-tricks.com\/?p=385769"},"modified":"2025-11-06T08:57:55","modified_gmt":"2025-11-06T15:57:55","slug":"explaining-the-accessible-benefits-of-using-semantic-html-elements","status":"publish","type":"post","link":"https:\/\/css-tricks.com\/explaining-the-accessible-benefits-of-using-semantic-html-elements\/","title":{"rendered":"Explaining the Accessible Benefits of Using Semantic HTML Elements"},"content":{"rendered":"\n

Here’s something you’ll spot in the wild:<\/p>\n\n\n\n

<div class=\"btn\" role=\"button\">Custom Button<\/div><\/code><\/pre>\n\n\n\n

This is one of those code smells<\/a> that makes me stop in my tracks because we know there’s a semantic <button><\/code> element that we can use instead. There’s a whole other thing about conflating anchors (e.g., <a class=\"btn\"><\/code>) and buttons, but that’s not exactly what we’re talking about here, and we have a great guide on it<\/a>.<\/p>\n\n\n\n

A semantic <button><\/code> element makes a lot more sense than reaching for a <div><\/code> because, well, semantics<\/em>. At least that’s what the code smell triggers for me. I can generically name some of the semantical benefits we get from a <button><\/code> off the top of my head:<\/p>\n\n\n\n