I've heard that inline styles, i.e. a style in a tag such as

<div style="float:left">

is a bad thing, and leads to maintenance problems. However if I'm styling an element which is only ever going to exist on one page, is it such a bad thing?

4 answers

0
points
This was chosen as the best answer

It's a bad habit to get into. The coder that comes along in a years time (which may be you) will not be expecting inline styles when they edit your stylesheet, and as inline styles take precedence over styles in a stylesheet then hours of frustration may ensue, when things don't change as expected.

Also, someone may edit your html without replacing the inline style...

But only you know your site and the maintenance it might need.

Answered over 6 years ago by Tony Crockford
danwellman 5600
1
point

It also breaks the 'seperation of content and presentation' paradigm and can lead to bloated pages that load slowly and are indexed badly...

Answered over 6 years ago by danwellman
1
point

Putting your styles in a separate .css file makes them much easier to edit, because all your styles are in one file (or a few, depending on your structure). You don't have to wade through tons of HTML to find the style you want to change. Also, .css files are cached in the browser, but inline styles are not, so if you made all your styles inline, the page would load much more slowly.

Answered over 6 years ago by Sasha Chedygov
0
points

It is hard to overwrite (with !important only). Floated boxes for example will break in Firefox while printing. You probably want to remove the float in your print stylesheet.

Answered over 6 years ago by Thomas Scholz