CSharpBeginner CSharpBeginner - 4 months ago 23
CSS Question

Direction rtl to all page

I have a long html page.

I want to change the direction of all text/tables to rtl.

How can i do that to all page instead of to change to any element the direction to rtl?


Thanks.

Answer

Using CSS:

* {
    direction: rtl;
}

Using JavaScript:

var children = document.children;
var i;
for (i = 0; i < children.length; i++) {
   children[i].style.direction = "rtl";
}

OR

document.body.style.direction = "rtl";

OR ( from evolutionxbox comment )

document.body.setAttribute('dir', 'rtl')

Using JQuery (even if you are not asking about):

$("html").children().css("direciton","rtl");

Inline Coding:

<body dir="rtl">

OR

<html dir="rtl">