|Important||This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.|
How to: Display Right-to-Left Text Using HTML Tags for Globalization
When writing ASP.NET Web pages, the best way to make text flow from right to left is to use the dir (direction) attribute. The dir attribute is usually placed in either the html or body tag, and then controls and HTML elements on the page inherit from the specified direction.
The tag to which the dir attribute is applied affects how the page appears, as follows:
When the value for the dir attribute is rtl (right to left) in the html tag, the page gets the correct extended styles set. On a bidirectional-enabled system, the page displays as a right-to-left page and a vertical scrollbar appears on the left side.
When the value for the dir attribute is rtl (right to left) in the body tag, frames and captions do not inherit the right-to-left direction.
There are other ways to set the flow of text, including the bdo tag for bidirectional override, Unicode characters that have embedded directional information, cascading style sheets, and so on. For more information, go to the Global Development Computing Portal on Microsoft.com and search for information about authoring HTML for middle-eastern content.
To set the dir attribute in an ASP.NET Web page
This example has a text box that accepts user input, which is a potential security threat. By default, ASP.NET Web pages validate that user input does not include script or HTML elements. For more information, see.
<html dir="rtl"> <!-- Or --> <body dir="rtl" >
To override the default direction for individual controls, set
dirfor each control to
<table dir="ltr" > <asp:TextBox dir="ltr" >