direction style property
Specifies or returns the text direction.
The direction property affects the horizontal rendering order only, the left and right sides of the margin, border and padding are not swapped.
Syntax:
You can find the related objects in the Supported by objects section below.
This property is read/write.
CSS page for this property: direction |
Possible values:
The type of this property is string.
One of the following values:
Takes the value of this property from the computed style of the parent element. | |||||||
Default. Left to right. | |||||||
Right to left. |
Default: ltr.
Example HTML code 1:
This example illustrates the use of the direction property:
|
||||
<head> <style> .ltr { font-size: 20pt; direction: ltr; } .rtl { font-size: 20pt; direction: rtl; } </style> </head> <body> <p class="ltr"> 0 1 2 3 4 5 6 7 8 9 </p> <p class="rtl"> 0 1 2 3 4 5 6 7 8 9 </p> </body> |
||||
|
||||
Did you find this example helpful?
|
Example HTML code 2:
This example illustrates the use of the direction property in JavaScript:
|
||||
<head> <script type="text/javascript"> function ChangeDirection (button) { var div = document.getElementById ("myDiv"); var dir = div.style.direction; div.style.direction = (dir == "rtl")? "ltr" : "rtl"; button.innerHTML = (dir == "rtl")? "right-to-left" : "left-to-right"; } </script> </head> <body> <div id="myDiv" style="direction:rtl;">0 1 2 3 4 5 6 7 8 9</div> <button onclick="ChangeDirection (this);">right-to-left</button> </body> |
||||
|
||||
Did you find this example helpful?
|
Supported by objects:
CSSStyleDeclaration, htmlElement.currentStyle, htmlElement.runtimeStyle, htmlElement.style
HTML elements:
a, abbr, acronym, address, b, bdo, big, blink, blockquote, body, button, caption, center, cite, code, col, colgroup, dd, del, dfn, dir, div, dl, dt, em, fieldset, font, form, h1, h2, h3, h4, h5, h6, hr, html, i, iframe, img, input:button, input:checkbox, input:file, input:image, input:password, input:radio, input:range, input:reset, input:search, input:submit, input:text, ins, isindex, kbd, label, legend, li, listing, marquee, menu, nobr, ol, optgroup, option, p, plaintext, pre, q, rt, ruby, s, samp, select, small, span, strike, strong, sub, sup, table, tbody, td, textarea, tfoot, th, thead, tr, tt, u, ul, var, xmp
Related pages:
External links:
direction (MSDN)
direction (Mozilla Developer Center)
direction (Safari Reference Library)
direction (W3C)
direction (Mozilla Developer Center)
direction (Safari Reference Library)
direction (W3C)
User Contributed Comments