Page is a not externally linkable
- Code, Content, and Presentation
-- HTML
---- Is It Okay to Use CSS and HTML in the Same Statement?


lucy24 - 10:04 pm on Jul 16, 2012 (gmt 0)


You can do absolutely anything inline that you can do with a proper stylesheet. It just looks clunkier.


/* these are my changes or additions */
p {blahblah...}
h1 {blahblah...}
/* now back to default styles */


That should make you feel safer ;) And of course you can save a copy of the default stylesheet with a name like "built-in-styles.css" so you can always go back to it.

Style from stylesheet:

p.myclass {font-family: sans-serif; text-align: left; margin-top: .5em; margin-bottom: 0em;}
...
<p class = "myclass">blahblah</p>


Inline style

<p style = "font-family: sans-serif; text-align: left; margin-top: .5em; margin-bottom: 0em;">blahblah</p>


I really do put the top and bottom margin in my boilerplate, because most browsers default to 1 em for both and I don't like the look. left-align is the default, but say it explicitly and you don't have to worry about centering or justification sneaking in where it isn't wanted.

If you wanted a whole series of paragraphs with the same formatting, you could put most of it in the div-- but not the margins, because those would only apply to the overall div. And you'd have to look at your built-in stylesheets to see if there are any default values for p (generic, regardless of class).


Thread source:: http://www.webmasterworld.com/html/4475562.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com