Jump to content

Template for CSS and JavaScript


retro-starr
 Share

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 comment
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 comment
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 comment
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 comment
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 comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...