dir=“rtl” vs. text-align: right. What is the difference between them?

扶醉桌前 提交于 2019-12-22 12:09:16

问题


The html attribute dir and the css text-align property acheive the same result. E.g. consider the two cases:

  1. dir="rtl"

<p dir="rtl">
		one two.
</p>
  1. text-align: right

<p style="text-align: right;">
		one two.
</p>

The only difference between these two results is the placement of dot. Why isn't <p dir="rtl"> one two. </p> translated to .owt eno? If it can't then what is the use of dir attribute at all?


回答1:


The placement of the dot is the crucial point of the difference between dir and text-align. Handling right to left scripts is much more involved than handling the alignment of the text. To understand better, read

https://www.w3.org/International/articles/inline-bidi-markup/uba-basics

A sequence of rtl characters such as سلسلة نصية الذهاب works automatically because of the Unicode bidirectional algorithm relying on the character's directional properties, but you need more to properly handle punctuation, images, and bidirectional text.

bdi is an element, not an attribute name.

don't get bdi confused with bdo. The former applies heuristics to guess the direction of text, the latter overrides the bidirectional algorithm (and is very rarely used).

For a more complete picture about how to work with RTL (or actually bidirectional) text in html, see

https://www.w3.org/International/tutorials/bidi-xhtml/index



来源:https://stackoverflow.com/questions/40157139/dir-rtl-vs-text-align-right-what-is-the-difference-between-them

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!