跳到正文
Skillpedia
网站与界面(前端)75k · #2816

direction-attribute

它能做什么

这项技能检查网页是否为其语言设置了正确的文字方向。适合构建从右到左语言网站,或包含混合方向内容的开发者。

适用场景

  • ✓当你的网站加入阿拉伯语、希伯来语、波斯语或乌尔都语内容时。
  • ✓当用户姓名或评论中混合了从左到右和从右到左的文字时。
  • ✓当菜单和布局对从右到左的读者显示颠倒时。

技能链接

https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/direction-attribute/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/direction-attribute/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“你能检查一下我的网站对阿拉伯语读者是否显示正确吗?”

每周 5 个新技能,1 分钟读完。

工作原理

智能体会检查页面及混合方向部分(例如用户评论)上的 dir 属性。在需要的地方,它会建议添加正确的值,或使用隔离标签。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Set text direction for RTL languages

Without proper dir attributes, RTL text displays incorrectly, UI elements appear backwards, and screen readers announce content in the wrong order.

Quick Reference

  • Set dir="rtl" on <html> for Arabic, Hebrew, Persian, Urdu
  • Use dir="auto" for user-generated content
  • Combine with CSS logical properties (inline-start, inline-end)
  • Test UI mirroring for navigation, icons, and layouts
  • Use bidi isolation such as <bdi> for inline mixed-direction user content

Check

Verify that this HTML document uses the appropriate dir attribute to indicate text direction for right-to-left languages like Arabic, Hebrew, or mixed content. Check user-generated inline text for dir="auto" or bidi isolation where names, handles, or snippets mix writing directions.

Fix

Add the dir attribute to the html element or specific elements with values 'ltr' (left-to-right), 'rtl' (right-to-left), or 'auto' for automatic detection. Use <bdi> or equivalent bidi isolation for mixed-direction inline content.

Explain

Explain how the dir attribute helps browsers and screen readers properly display and navigate text in different writing directions.

Code Review

Review templates, server-rendered HTML, and shared components that output markup related to Set text direction for RTL languages. Flag exact elements, attributes, and routes where the rendered HTML violates the rule. Inspect user-generated inline content, not only page-level locale wrappers.


For full implementation details, code examples, and framework-specific guidance, see references/rule.md.

Rule page: https://frontendchecklist.io/rules/html/direction-attribute

常见问题

dir 属性有什么作用?

它告诉浏览器文字的流动方向,是从左到右还是从右到左。

什么是双向隔离(bidi isolation)?

它使混合方向的文字(例如另一种文字的姓名)不会干扰附近的文字。这项技能建议为此使用 bdi 标签。

它涵盖布局镜像吗?

这项技能建议测试导航、图标和布局是否正确地镜像。

详情

作者的原始描述

Use when reviewing templates, rendered HTML, or shared components related to Set text direction for RTL languages. Validate the final browser-facing markup, not just the source framework abstraction.

repo: thedaviddias/Front-End-Checklist

热度

GitHub 星标
75k
排名
#2816
许可证
MIT
更新时间
2026/10/31

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能