HTML-dir-Attribut
The dir attribute is a part of Global Attributes and specifies the text direction of an element’s content. Read and find out on what elements it can be used.
Das HTML-Attribut dir legt die Textrichtung des Inhalts eines Elements fest. Es ist wichtig, um HTML in Schriften von rechts nach links zu unterstützen (z. B. Arabisch, Hebräisch usw.). Zahlreiche Sprachen werden mit diesen Schriften geschrieben.
Sie können dieses Attribut bei jedem HTML-Element verwenden. Es ist Teil der Global Attributes.
Das Attribut dir kann die folgenden Werte haben:
- ltr: zeigt den Text in Schreibrichtung von links nach rechts an. Dies ist der Standardwert.
- rtl: zeigt den Text in Schreibrichtung von rechts nach links an.
- auto: lässt den Browser die Textrichtung anhand des Inhalts bestimmen, typischerweise mithilfe des ersten starken Richtungszeichens.
Syntax
Syntax des HTML-Attributs dir
<tag dir="ltr|rtl|auto">content</tag>Beispiel für das HTML-Attribut dir:
Beispiel für das HTML-Attribut dir
<!DOCTYPE html>
<html>
<head>
<title>Title of the document</title>
</head>
<body>
<p dir="rtl">Example of the HTML "dir" attribute:</p>
</body>
</html>Practice
Übung
What is the purpose of the HTML 'dir' attribute according to the page from w3docs.com?