DEV Community

Discussion on: There's nothing wrong with inline styles

Collapse
 
geewhizbang profile image
Geoffrey Swenson • Edited

A perfect example of why this was terrible was the horrible html generated by various ASP. Net components. It was all inline and then getting it to do something different became a huge battle of either configuration hell or overriding things with !important, I spent more time turning these things off that I just rolled my own components as user controls instead.

Inline styles have not been needlessly demonized. They really are appalling. The rather limited excuse provided here is practically a rare exception that proves the rule.

And even in the case here, it puts a whole bunch of work into putting the style information into the wrong place, you can't reuse it without writing new code. Even if you don't need to reuse the styles elsewhere it isn't any more work to separate concerns and let the html control which objects and text you are rendering and let the css styles control the appearance as gawd intended.

And besides my stylesheet contains a lot of simple reusable elements maybe yours should and that's why you think that inline styles are ok.

I used to use a page layout program that forced you to create a style for certain properties. It was not a bad thing, it forced you to use a design that was well conceived and editable while the gawdawful Microsoft Word lets users go hog wild with local overrides which are the equivalent of inline styles and the document quickly becomes an unmaintainable mess.