|
| |
Warning! -Take the wrong comment type out of your stylesheets NOW
View related threads:
(in this forum
| in all forums)
|
Logged in as: Guest
|
|
|
gorilla
Posts: 2974 From: Denmark Status: offline
|
Warning! -Take the wrong comment type out of your style... - 11/19/2003 14:23:24
All too often I see something like this in the head of people's pages: <style type="text/css"> <!-- css here --> </style> And in external stylesheets also. In each case it is is very very wrong. - You should never use HTML comments in your style sheet. However it is extremely wrong in embedded style sheets and is going to give a lot of people a lot of trouble in the not too distant future. HTML COMMENTS ARE FOR HTML: <!-- qwertyuiop --> CSS COMMENTS ARE FOR CSS: ONLY use css comments in style sheets. /* This is the only right way to comment CSS */ Anything else is sematically and syntactically incorrect and a said above will give you problems in the not too distant future. Why? 1. Putting in HTML comments was an early hack to prevent non css aware browsers from trying to parse the css. 2. It is not now, never was, and never will be part of the standard. 3. Some gecko based UAs are starting to "silently remove" anything between html comments. 3a: Yes I'm serious, we're currently alpha testing several UAs that do this. 4. The implications should be very obvious. To repeat your css should look like this: <style type="text/css"> css here </style> and not like this: <style type="text/css"> <!-- css here --> </style> Edited: to more clearly reflect an implicit point made by c1sissy in posting below. jb
< Message edited by gorilla -- 11/19/2003 4:53:40 PM >
_____________________________
Mháircaish Signature self-censored to protect the sensibilities of the thin-skinned . May we never confuse honest dissent with disloyal subversion. – Dwight D. Eisenhower
|
|
|
|
gorilla
Posts: 2974 From: Denmark Status: offline
|
RE: Warning! -Take the wrong comment type out of your s... - 11/19/2003 18:33:57
quote:
ORIGINAL: c1sissy 1. In regards to what Shirley posted. Isn't this a different means of commenting? 2. The one that Shirley has referred to is the one that you would use for commenting OUT code? Say I'm trying something not sure if I like it, but don't want to get rid of it while I try something else, I would just comment it out, and if I decide that this is what I want I would just remove the comments? As well as the reason that is mentioned in the thread that Shirley posted. 3. The commenting out that is referred to in your posting is to keep other browsers that aren't css compatible from seeing the styles? Don't mean to be a stubborn student here, but lol, just want it all to make sense <edit> 4. http://www.w3.org/TR/2003/WD-CSS21-20030915/syndata.html#comments How does this apply to using or not using? and is this standard or not standard?</edit> 1. No, it is the correct way of commenting in a - an external css file. b - an stylesheet embedded in the document. 2. Yes, and that is indeed a very good use for it. But it is by no means limited to that. Comments are there to for example, help you remember which bit of the file refers to which selectors. EG: /* Start of left navigation styles */ stuff /*End of left navigation styles */ /* Start of right navigation styles */ stuff /*End of rigth navigation styles */ /* Start of main content styles */ stuff /*End of main content styles */ /* Start of hacks to cope with broken box model in ie5.5 styles */ stuff /* End of hacks to cope with broken box model in ie5.5 styles */ and so on. Comments are just that. any text between this: /* and this */ will simply be ignored by the UA. IOW you can put in anything you like upto and including the collected works of William Shakespeare and as long as they are between /* and */ they'll be ignored. 3. Yes, they are html comments. HOwever as I have clarified further below with a quote from the relevant document for anything above html3.2 it is sematically and syntactically incorrect to use it. Forthcoming gecko based UAs can (and will) "silently remove" anything between html comments. with a very unpleasant effect upon your page. - This is per spec btw. 4. Key paragraph is: quote:
CSS also allows the SGML comment delimiters ("<!--" and "-->") in certain places, but they do not delimit CSS comments. They are permitted so that style rules appearing in an HTML source document (in the STYLE element) may be hidden from pre-HTML 3.2 user agents. See the HTML 4.0 specification ([HTML40]) for more information Emphasis added by me. - So not part of html 4.0 bis. 5. Be as stubborn as you like it needs to make sense. 6. That page btw is one of the more important ones in the spec. jb
< Message edited by gorilla -- 11/19/2003 6:36:55 PM >
_____________________________
Mháircaish Signature self-censored to protect the sensibilities of the thin-skinned . May we never confuse honest dissent with disloyal subversion. – Dwight D. Eisenhower
|
|
New Messages |
No New Messages |
Hot Topic w/ New Messages |
Hot Topic w/o New Messages |
Locked w/ New Messages |
Locked w/o New Messages |
|
Post New Thread
Reply to Message
Post New Poll
Submit Vote
Delete My Own Post
Delete My Own Thread
Rate Posts
|
|
|