If I'm using a technology like Grails. It's really easy to wind up with inline styling.
Are there any downsides to auto-generating code with inline styling? Is this considered bad practice? Why?
|
If I'm using a technology like Grails. It's really easy to wind up with inline styling. Are there any downsides to auto-generating code with inline styling? Is this considered bad practice? Why? |
||||
|
|
|
There are two main reasons why this auto-generated inline styling is bad:
Moreover, auto-generated code is mostly limited to what it is capable of doing. In CSS, I know how to create a shadow or a gradient which will work in Chrome, Firefox and other normal browsers. I also know it will not work in Internet Explhorror. If you use auto-generated code, in most cases (today there are a few exceptions), either it will not even let you create a shadow or a gradient, or it will do it, but will not tell you that it works only in some browsers¹. Finally, consider a following scenario. You've created a website which uses auto-generated code to change the color of the buttons to gray. There are around 30 pages with an average of 5 buttons per page. Two days before the release, you're asked to switch the color from gray to teal:
¹ Of course, this is not an issue if you're knowledgeable about CSS and you know exactly what you're doing. |
||||
|
|
|
Downsides, to my eye:
There a are times when you can't escape inlining style info: it's sending HTML-formatted emails. |
|||
|
|
|
Yes, inline styling is considered very poor practice. You have no centralized location for your styles, which is why (ideally) you want to link to an external style sheet. With an external style sheet, you make a few simple edits and your changes are reflected site-wide. With inline styles, you have to go hunting for those styles and make your edits. |
|||||||||
|