Forum Moderators: not2easy

Message Too Old, No Replies

css syntax ##

         

webdesignerq

3:11 pm on Apr 11, 2004 (gmt 0)



why use comment tags in a stylesheet-syntax
<style type="text/css">
<!-->
somestyle
-->
</style>
and why not like this
<style type="text/css">
somestyle

</style>

photon

12:48 pm on Apr 12, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The HTML comment tags "hide" the CSS code from older browsers (such as Netscape Navigator 4) which may not be able to understand more advanced CSS.

choster

1:26 pm on Apr 12, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Since that comment syntax is the same as what XML uses, such a stylesheet might be ignored in an XHTML page. I suggest loading stylesheets externally whenever reasonable.

webdesignerq

1:33 pm on Apr 12, 2004 (gmt 0)



So you should create alternative css for
most common browsers like IE, Netscape,Opera
AND again for mac, linux and win.
Any good tutorials?

photon

2:23 pm on Apr 12, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you search on "css browser compatibility chart" you'll find several sites that list which aspects of CSS are supported on which browsers, broken down by version and OS.

On the question of NN4 compatibility, I pretty much ignore it and let those users see just a text rendering of my pages. My layout is such that it still looks okay that way, they just don't get the pretty colors. :) But for some sites that's not an option. In that case, some may recommend a separate layout based on tables for those users.

It is possible to use "browser sniffing" to serve specific stylesheets to specific browsers. But generally you just want to write code that will validate, then tweak and/or add "hacks" as required. That should take care of most modern browsers. One piece of advice that seems to be repeated often here is to check your code against a Mozilla browser (it seems to be most compliant with standards), then tweak as necesary to get IE to play nicely.

I'd suggest also that you become familiar with the box model, and the issues surrounding it in IE. That (for me, anyway) is the problem most frequently encountered.

DrDoc

3:15 pm on Apr 12, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



"hide" the CSS code from older browsers (such as Netscape Navigator 4)

It doesn't hide CSS from NN4. You'd have to go back way further than that for the HTML comments to have any affect at all.
I'd recommend not using them.

photon

8:19 pm on Apr 12, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



DrDoc--

You're right of course. I was thinking of

@import
.

TheDoctor

11:57 pm on Apr 13, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



And the one thing you definitely can do with NN4 and CSS is to let the user see the pretty colours. You can't do much else, but it helps make the site look cheerful, if basic.

ooze99

12:23 am on Apr 14, 2004 (gmt 0)

10+ Year Member



The easiest way to hide CSS styles form netscape 4.x is to wrap them using this hack

/*/*/

.someStyles {}

/* end hack */

That validates and wont get passed to older netscapes.