Reputation: 611
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.
Upvotes: 10
Views: 19975
Reputation: 41
You can use jQuery.
$('body').children().css('direction','rtl');
Or use pure Javascript:
document.getElementsByTagName('Body')[0].style.direction = "rtl"
Upvotes: 4
Reputation: 11271
* {
direction: rtl;
}
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')
$("html").children().css("direction","rtl");
<body dir="rtl">
OR
<html dir="rtl">
Upvotes: 19
Reputation: 3350
Javascript
document.body.style.direction= "rtl";
HTML
<body dir="rtl">
Upvotes: 1
Reputation: 528
The direction property in CSS sets the direction of of content flow within a block-level element. This applies to text, inline, and inline-block elements. It also sets the default alignment of text and the direction that table cells flow within a table row.you can use
body {
direction: rtl; /* Right to Left */
}
or There is an HTML attribute for setting the direction as well
<body dir="rtl">
It is recommended you use the HTML attribute, as that will work even if CSS fails or doesn't affect the page for any reason.
Upvotes: 5
Reputation: 675
using css:
html * {
direction: rtl;
}
using jQuery:
$('html').children().css('direction','rtl');
Upvotes: 0