Utilising cssText to set styles with JavaScript

Posted by Rajat on Stack Overflow See other posts from Stack Overflow or by Rajat
Published on 2010-03-17T06:46:19Z Indexed on 2010/03/17 6:51 UTC
Read the original article Hit count: 271

Filed under:

I was going through Nicholas Zakas presentation on JavaScript here : http://www.slideshare.net/nzakas/writing-efficient-javascript (slide number: 89/139)

He recommends using cssText property whenever you are setting a bunch of styles through JavaScript. The best solution is obviously adding those styles to a class and then using JS to add the classname to an element.However, in many situations, We resort to just setting the properties directly within JS when the number of properties are low.

It seems from his presentation that using cssText property would be more efficient in such scenarios.I tried to look up more on the property but couldn't find much information.

Has anyone used the 'cssText' property ? It would be great to have some more technical info on how the property helps.

© Stack Overflow or respective owner

Related posts about JavaScript