Your Ad Here

Inline styles


Inline styles are valid in HTML 4.01, but are so strongly recommended
against that they are practically verboten, while in early proposed drafts of
XHTML 2.0 the style attribute is fully deprecated and dropped from the specification
altogether. In HTML 4.01 and XHTML 1.0, with the style attribute,
you can insert style declarations directly into any HTML tag.
Before you use an inline style, however, think about it: what is the difference
between that and, say, using the deprecated <font> tag? The answer is, not
a whole lot. Don’t use inline styles: the styles themselves are not reusable
by other elements on the page, they can’t be overwritten by embedded or
external styles without the use of !important, they increase page-rendering
time, and they quickly become a maintenance nightmare. Implementing your
styles in other places will be a lot more powerful and portable for you in the
long run.


You’ll probably use comments in your styles,
whether to help you organize and notate what
you have created (and why) or to make logical
sections of the styles. Commenting your code is
a really good practice and well worth a little extra
time. When you come back to the code three
months (or even three days) later, you’ll be happy
that you did. After all, you want to be solving CSS
mysteries, not creating them!
The comment syntax in styles is as follows:
/* comment */
Comments can be single words up to multiple
lines. You can break lines and have carriage
returns inside of the comment tag, and it won’t
affect the styles one whit.
/* A comment with
multiple lines of text. */
The one thing you shouldn’t do is nest style
comments inside each other.
The comment element is also incredibly useful
for creating titles for groups of styles, and for
temporarily removing a style for testing or
troubleshooting.



0 comments:

Post a Comment

Popular Posts

Recent posts