dirname
An attribute for text fields. Add dirname and the browser submits a second field alongside the value: the direction the text was typed in, ltr or rtl. Chrome and Safari have shipped it since 2012. Firefox 116 completed the set in August 2023, and the 30-month clock ran out on 1 February.
Delete: the direction-guessing code. If your site stores user text that might be Arabic or Hebrew, something today inspects each comment to decide whether it needs dir="rtl" when displayed again, a client script or a server-side heuristic. The browser already knows; let it tell you.
<!-- a script sniffs the value, fills a hidden field -->
<input type="text" name="comment">
<!-- the browser reports direction at submission -->
<input type="text" name="comment" dirname="comment.dir">
<!-- comment=%D9%85%D8%B1%D8%AD%D8%A8%D8%A7&comment.dir=rtl -->One seam at the edges. On input types where the spec says the attribute does not apply, current stable runs disagree: Firefox 153 and Safari 26.5.2 submit the direction pair for a month input anyway, while Chrome 151 and Edge 150 omit it. Keep dirname on plain text fields and textareas, where every current run passes, and treat the extra field as optional on the server. A browser too old to know the attribute never sends it: your default direction applies, and nothing breaks.