Is there a problem to using javascript for styling content?
My website requires javascript. There is this text on my website that I want vertically centered. The text could be either 2 lines or 3 lines long. With javascript I could vertically center it pretty easily. The CSS ways to vertically center it seem complicated and include IE hacks.
So, is there a downside to me using javascript for this styling, considering I have already decided that my website will require javascript?
The downside is that if you have any long-running page, say an ad fails to load, etc hanging the document.ready event…your styling wouldn’t be applied until the document completed rendering and the javascript then ran. (Note: This assumes your script fires in the ready event, usually the case since you’d want the elements to be there)
Basically you’d get a flash of non-styled content in the case of anything delaying the ready event. Whether that matters, up to you, but personally I’d stick to CSS where possible.