Prev | Current Page 47 | Next

Charles Wyke-Smith

"Stylin' with CSS: A Designer's Guide 2nd Edition"


HOW CSS WORKS 29
Here are some things you need to know about inline styles:
??? Their scope is very restricted. An inline style only affects the tag
to which it is attached.
??? The practice of using inline styles is simply another way of putting
presentational markup directly on the tags, as we did in
days of yore. Adding inline styles everywhere is as bad for the
portability and editability of your markup as adding deprecated
HTML attributes, such as FONT. Inline styles should be generally
avoided.
??? On those rare occasions when you need to override a style in
just one speci?¬? c instance and there is no better way to do it,
you can create an inline style and not feel too guilty about it.
That said, you could almost always avoid using inline styles
by adding a unique ID or class to the tag in question and then
writing a corresponding style in your style sheet.
??? Using an inline style is a good way to try out a style before you
move it into the style sheet (see ???Linked Styles??? on the next
page). Just remember to clear out the style attribute entirely
once you achieve the effect you want and then cut and paste
just the style itself into the style sheet. If you have it in the
markup, that inline style will always override whatever change
you try to make to that particular tag from the style sheet, and
you can spend hours trying to ?¬? x the style sheet when the problem
is, in fact, hidden in the markup.


Pages:
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59