HTML attr dir

From Htmlpedia
Jump to: navigation, search

HTML attribute dir

This attribute specifies the base direction of directionally neutral text (i.e., text that doesn't have inherent directionality as defined in UNICODE) in an element's content and attribute values. It also specifies the directionality of tables. Possible values:

  • LTR: Left-to-right text or table.
  • RTL: Right-to-left text or table.

Example

In this example, the text for the whole page is display left to right except for the div with the ID "righttoleft" which will be right to left.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
</head>
<body>
left to right
<div id="righttoleft" dir="rtl">
right to left
</div>
</body>
</html>