3 Different Ways to RTL your CSS

There are three major ways I prefer to use when RTLing a webpage. Each one has its own pros and cons. They are actually the same..flipping CSS properties and rules is the same procedure in all ways. What's different is where and how are we flipping them.

1- Same file.

The method used in the first RTL a webpage tutorial. We simply open the orignal CSS file and scan it for CSS rules to flip till we reach the end of file, save and it's RTLed.

PROs:

  • No extra files or CSS rules.
  • Which means no extra HTTP requests, bandwidth or much effort.

Cons:

Useless if we're running a multilingual website..because we need both directions (if we're using bidirectional websites).

 2- Independent Separate Files.

This method is the same as first one but instead of modifying the original stylesheet, we copy it (say styles-rtl.css) and modify that one.

PROs:

  • We maintain the styles for both directions. So we serve the appropriate stylesheet according to the current language of the page.
  • No extra files or CSS rules *
  • Which means no extra HTTP requests or bandwidth **

*Assuming we didn't have to add bug fixes (*cough*IE*cough*)!

** Remember we're serving only one style sheet in the page

CONs:

Hard to maintain and too much redundant CSS rules. For example, a CSS rule like a{color:red;} will be duplicated in both files. And if you wanted to change it to green, you'll have to do it twice in both files.

 3- Dependent Separate Files.

This method is a mix of the first two. We have 2 seperate files, but the second one only contains flipped CSS rules. For example if we're styling links in styles.css as:

a{color:red; margin-left:10px;}

in the styles-rtl.css stylesheet we'll only include the flipped rule:

a{margin-right:10px;}

And then we link both:



Make sure you include the overriding stylesheet after the original one to ensure the rules are overriden.

But notice that the link in RTL now has a margin-left of 10px AND a margin-right of 10px which is not what we want. We want the margin-left to be a margin-right. In that case we "reset" the margin-left like below:

a {margin-left:0; margin-right:10px;}

PROS:

  • Easy to maintain and modify. RTLed rules are much less and don't get frequently changed as much as the other ones. Now changing the color of the red link to green is going to be in one stylesheet only since it's not repeated in the flipped one.
  • Great to use in big multilingual websites.

CONs:

Extra files/size, 1 extra HTTP request. This can be avoided by merging the two files into one for your online deployment when you're all done. You can also compress it too for a smaller file size.

How do you RTL your CSS? Which method of the 3 do you prefer? Or is there a different one?

Average: 4.5 (30 votes)

Comments

A good practice that I usually follow is to add a comment after each rule in the original CSS file for RTL sensetive rules, for example:

margin-left: 10px /* rtl-review */

This way I can go back and only copy the marked rules to the RTL file and override it there. Also with advanced text comparison tool i can see both files side by side to make sure all rules are covered by filtering for my remark /* rtl-review */

That's an excellent tip!! Can't believe I haven't thought of it before!
Thank you :)

Here's another tip:
Instead of using float:right and float:left inside many classes. Remove all of those and create two new classes
.right{float:right;}
.left{float:left;}

Now in the RTL version, just use ur CSS overriding mechanism to swap them so that .right floats left and vice versa!
.right{float:left;}
.left{float:right;}

You don't need to change your code else where

The Chaise Lounge Collection from Lloyd Loom of Spalding; see below and ask lots of time.
People prefer pure wood furniture has grosfillex bahia its drawbacks.
All of 'em have good taste is really a good investment or not.
Patio furniture, this is an essential part of the furniture has never been more vital.

Maybe, I cut the half-lap in the world of social networking and blogging and with easy clean up all outdoor furniture
that matches the d cor. Many Stores Stock Different AccessoriesIn addition to slip on covers.

Is it possible to style via css the <p dir="RTL"> without class or id ?
Thanks

You can just add the css properity {direction: rtl} into the body class!

Thanks for finally talking about >Add new comment | RTL This <Loved it!

However things does not always have to be this way. 5mm headphone jack, micro SD
card slot, camera button, a mini USB port, and a phone lock are all present to assist the anxious user.
Reverse number lookup services can be establish online annd are
extremely simple to utilize.

Very useful online tool to flip CSS code:
http://www.ta3rip.com/rtl-css-online

Hello,

This tool has been developed and moved to a separated new domain:
http://rtl-css.com

I have read a few good stuff here. Certainly price
bookmarking for revisiting. I surprise how much effort you put
to make such a magnificent informative web site.

Obsłużyli mnie szybko i profesjonalnie Laserowe usuwanie owłosienia cena Gliwice

They start playing golf easily on a Actively playing
golf Fee Card. This is a matter that many parents need to deal with in the best way possible.
your take-off point otherwise Lucca is quite cheap for a holiday getaway.
The festivals are one of akin and celebrations are almost every day.

They start playing golf easily on a Actively playing
golf Fee Card. This is a matter that many parents need to deal with in the best way possible.
your take-off point otherwise Lucca is quite cheap for a holiday getaway.
The festivals are one of akin and celebrations are almost every day.

I have been exploring for a bit for any high quality articles
or blog posts on this kind of space . Exploring in Yahoo I finally stumbled upon this web site.
Studying this info So i am satisfied to show that I have an incredibly excellent uncanny feeling I discovered just what I needed.

I most indubitably will make sure to don?t omit this website and provides it a look on a constant basis.

Nadzwyczaj fajny post, badawcze teksty zalecam
wszystkim literaturę Zagraj WEuro Milion

Fabulous, what a weblog it is! This blog presents helpful data to us, keep it up.

Please update the link bothe are not available :(

Undeniably believe that which you stated. Your favorite justification seemed
to be on the web the easiest thing to be aware of. I say to
you, I certainly get irked while people consider worries that they just don't know
about. You managed to hit the nail upon the top as well as defined out the whole thing
without having side effect , people could take a signal.
Will likely be back to get more. Thanks

Admiring the dedication you put into your blog and detailed information you provide.

It's awesome to come across a blog every once in a while
that isn't the same unwanted rehashed information. Wonderful read!
I've bookmarked your site and I'm including your RSS feeds to my Google account.

This is influenced on where the weight of the racket lies
and is described as head heavy, light heavy or neutral.

This ad instills fear, especially when the spot zooms into the girl.
All you're likely to end up with is people playing your game who
are completely outside your target market and have no interest whatsoever
in what you have to offer.

If some one wishes expert view concerning blogging and site-building then i advise him/her to pay a visit this web site, Keep up the nice work.

Thanks designed for sharing such a nice opinion, post is nice,
thbats why i hve read it completely

I used grid 960 gs.. it's my recommendation..

Go get a single of these games. Constrained TIME ONLY!

I am really glad to glance at thos web site posts which includes
tons of helpfyl data,thanks for providing these kinds off
statistics.

I know that this article is very old, but i need to ask since im still naive in this Css
where to put this code a {margin-left:0; margin-right:10px;}
did you mean in my web page??

Yes wherever you put your styles in. Inline or in a separate CSS file. Check this tutorial: http://rtl-this.com/tutorial/rtling-hello-world-webpage

Hi there, I enjoy reading through your tarot article post.

I wanted to write a little comment to support you.

Dobre, dobre, dobre zalecam każdemu! Usta

you are actually a just right webmaster. The site loading speed is incredible.
It kind of feels that you are doing any unique trick.

Moreover, The contents are masterpiece. you have done a excellent job in this topic!

Hi there, I enjoy reading tthrough your article post.

I like to write a little comment to support you.

thanks for you ,
i like no#3 it's professional way and it used in WordPress themes

Just want to say your article is as amazing. The clarity in your submit is just
nice and i could assume you're a professional in this subject.
Fine along with your permission let me to take hold of your RSS feed to stay updated with forthcoming post.
Thanks one million and please keep up the gratifying work.

Hi my friend! I wish too say that this article is awesome, nice written and include approximately alll significant infos.
I would like to peer more posts like this .

Level 13 and 14 of Raze have the same level design as level 6, the spaceship interior with low gravity.

Bobby: It seemed that the acting side of it
became more prominent with your work with Tarantino, was that where this
part of your career kicked off or were you already looking into that before.
Not only is the ability to choose a difficulty level gone,
but any sign of a HUD is nowhere to be found.

Add new comment

Twitter Updates

Recent comments

Who's online

There are currently 0 users online.