Jump to content

Style in comments


L.Adlon
 Share

Recommended Posts

I was looking at one of the sites I made a few years ago, and noticed that on the main page, I had the style definitions, (in the <head> of the page),within HTML comments... I'm assuming as a precaution against browsers that didn't understand CSS style or something?

 

Ex:

 

<!--

.redtext {color:red;}

.bluetext {color:blue;}

-->

 

So, does that technique ring a bell to anyone? Is it still a thing? I'm assuming these days that you can safely put style definitions in the head without putting it within a comment, right?

Link to comment
Share on other sites

It's a technique that's useless today.

 

Back then in the late 90s when not all browsers had implemented the <style> tag, text between <style> tags would show up on the page in browsers that didn't support it.

You'll see the same thing done with <script> tags on websites with developers who aren't sure why it was done and continue to do it because that's what they were taught.

 

It takes decades for old irrelevant practises to die out.

Link to comment
Share on other sites

Cool. Ya, I was surprised to see that in that one page of mine. All the others don't have that. I guess that page was created back when I was still learning (...well, I totally still am, but you know what I mean), and that's what was suggested at the time.

 

Okay, I'll get rid of those. I figured they were redundant these days.

 

Thanks again, Ingolme.

 

Cheers!

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...