Jump to content

Template for CSS and JavaScript


Recommended Posts

Remove the <!-- comment --> tags. Long ago, they were intended for browsers that did not recognize the "new" <script> tag. But all modern browsers recognize script and style tags, so these sorts of comment tags are 100% unnecessary (and incorrect in the case of the style element).Other than that, the selector, braces, ruleset pattern is fine.

Edited by Deirdre's Dad
Link to post
Share on other sites
Couldn't the same be said about using them in javascript? Just for poops and giggles, what would be the correct way for the style element?
Yes, and it was.The correct way is what you had, minus the HTML comments... and the "//" at the end, i.e.
<style type="text/css">selector{	declaration;}</style>

The indenting (or lack of) is a matter of developer style - it doesn't affect how CSS works.

Link to post
Share on other sites

The correct way was just to use HTML comment tags without the // before the closing tag, like so

<style type="text/css"><!--selector{declaration;}--></style>

The // was used to hide the closing tag from browsers that DID recognize JavaScript.Seriously, no one uses a browser THAT old anymore. We're going deep into 90's technology here. Your precaution was appropriate maybe through 2002 or so, but no longer. A browser that old simply cannot render modern HTML without making a total mess of things, and in most cases would only work on an operating system so old that a computer running it would fetch maybe $5 at a yard sale.You might find this interesting: http://en.wikipedia.org/wiki/Cargo_cult_programmingboen, should you move this part of the thread to a new thread?

Edited by Deirdre's Dad
Link to post
Share on other sites
boen, should you move this part of the thread to a new thread?
My thoughts exactly... I was only waiting for retro-starr to be "done" so that he doesn't cross-post by accident.
Link to post
Share on other sites

Oh no, it does... you aren't the first person to ask this kind of question... well... you're the first to phrase it as a "template", but the comment bit is asked every once in a while. Hopefully, someone will see this topic instead of posting a new one.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...