Question 1:
I've tested screen readers, but at the time I did not pay attention to that. Do they identify the direction of the text by the attribute, or are they preconfigured?
Neither one nor the other. They do not read based on direction, but rather on the order in which the texts appear in the HTML source code (from beginning to end). [View Reference]
Question 2:
Can we omit and maintain the direction using just the CSS (direction: rtl), or does the dir attribute have any other application?
They have the same application, according to W3C specification.
However, preferably use the dir
attribute, according to W3C recommendation :
Since direction is an integral part of the document structure, a markup should be used to determine the direction of a document or piece of information, or to identify points in the text where the bidirectional algorithm is not sufficient to achieve the desired direction .
However, the style applied by CSS is not permanent. It can be disabled, ignored, unrecognized, or changed / replaced in different contexts.
Pictures [..]
Try not to simply connect the CSS style to the general element to achieve the effect.
HTML or XHTML rendered as text / html
Use markup only. The CSS2 recommendations indicate the use of markup for bidi HTML texts. One can actually say that HTML conforming user agents can bypass CSS bidi properties. Because the HTML specification clearly defines the expected behavior of user agents in relation to bidi tagging.
Note:
Note that the Unicode specification already assigns a direction to the characters and defines the Bidirectionality Algorithm (BIDI) for determining the most appropriate text direction.
However, it is required that the dir
attribute be used in HTML. In addition, W3C specifies that dir
should not be inferred from the language ( lang
).
HTML 4.01:
If you are using the pre-HTML version 5 version, you will have to specify the LTR
or RTL
values for the dir
attribute.
( See HTML 4.01 specification 8.2 .)
HTML 5:
From HTML 5, you can also use the auto
value. The direction will be defined according to the first character "strongly typed", that is, belonging to an alphabet - quotes, commas, numbers, and the like do not count.
Given the low complexity of this algorithm (unlike BIDI), only use this value when the address is not previously known as internationalized dynamic content. A h1
containing content coming from the database, for example. It is almost certain that there will be problems if you use the tags html
or body
- to set the direction of an entire document.
( See HTML Specification 3.2.5.6 5 ).