Forum Moderators: not2easy
I have a couple of questions regarding inlining CSS
into the body of a page and using the
<!--
and -->
(for hideing the CSS from browsers that
do not support it.)
Q. 1. Do you need to include them when
inlining CSS into a page for each individual selector,
and declaration?(to hide it from browsers that do not support it)
Ex. <p style="font-family: verdana; color: red;">
Q. 2. If needed, how do you do it for this example?
Please explain and show an example if it is needed to
do this.
Q. 3. If it was needed, is this the right way for
each individual selector and declaration on a page?
Ex.
<!--
<p style="font-family: verdana; color: red;">
--></p>
****This is just a guess.
Q. 4. Will it display properly without it? How will it display in browsers that do not support it? Will it look ok?
I hope you don't need them when inlining CSS into
the body of a page. I'm new to CSS and inlining and they might be dumb questions but
I want the text to display properly on my pages.
Can anyone please help me?
Please address each question.
Thank you to all:)
frenzy77
As for using comments for a style block between a <style type="text/css"> and </style> tags, it is not usually necessary, but you may want to do so if you have an abnormally-high number of visitors using very ancient browsers (read Netscape 2).
If you are using XHTML rather than HTML, then you should never use comments to hide styles.
For example, if you envision that you might want a red Verdana paragraph anywhere else in your entire site -- and particularly if you'll want that red Verdana paragraph in a lot of places -- use an external style sheet. Create a class in your style sheet called, oh, let's call it .redver Then in your paragraph you put <p class="redver"> And everywhere in your entire site you can use <p class="redver"> and you'll get exactly that same style, every time.
Suppose later on you decide that all red Verdana paragraphs should also be bold..... With inline styles, you have to find every instance of <p style="font-family: verdana; color: red;">, everywhere in your site, and change it. With a linked stylesheet you just add font-weight:bold to your style declaration for redver.
Using CSS is better than littering your pages with font tags, but using lots of inline styles really isn't much, if any, improvement over font tags.