Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

<div class="text-italic"></div>

Come on.

<em>This is my italic text.</em>



From a WCAG point of view you might want the top one instead, some screen readers read content in <em> in a different tone, which may not be intended.


Even then the equivalent of an em or i is a span, not a div.


<em> is a semantic element, and doesn't necessarily have to be italic. There are lots of use cases for italic text outside of <em>s.


Use <i> if your use case is "alternate voice or mood" or "different quality of text, such as a taxonomic designation, a technical term, an idiomatic phrase from another language, transliteration, a thought, or a ship name in Western texts"

https://html.spec.whatwg.org/multipage/semantics.html#the-i-...


Shouldn't that be <span> not <div>?


Using a framwork that generates html out of something else (XML but let's not get into the whys and whatfors) and I literally cannot use <em>, <i> or any other tag. I need to use a class and set the style in the CSS file.

Edge case? Maybe. Just don't dismiss something that doesn't immediately fit your own use-case.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: