re: Best Practices for HTML VIEW POST

VIEW FULL DISCUSSION
 

People seem to hate on using divs as wrappers, when really all that needs to be done is to add ‘role=“presentation”’ for screen readers to ignore it and dig deeper.

 

What scenario would you use that for?

 

If I was using a div within a section to create a 50-50 layout of image and content, applying flexbox classes to the div, I would also add role="presentation" so that the div itself would be ignored by screen readers, but the content would still be easily findable.

Yeah yeah I see, thanks! Good to know there’s a way to make screen readers ignore something.

I think the “hate” on using divs is more from using a div when there is a semantic element that is better to use.

Eg:
<div role=“navigation”> vs <nav>

So using div isn’t a no-no, it’s just a last-resort if there isn’t a semantic element for the use case. This is in contrast to what may have been a trend of excessive use of divs.

code of conduct - report abuse