Possible Duplicate:
What is the usage of comment notations in style tag?
I was wondering that often when writing css code inside a html document there is <!--
just behind the style tag. So for example: <style type="text/css"><!--
body { text-align: center; } --></style>
In my knowledge this is a html comment but why is it put inside the style tag, whats the sense? Is it to exclude certain browsers which will see it as a comment?
The <style> tag is used to define style information (CSS) for a document. Inside the <style> element you specify how HTML elements should render in a browser.
The <style> HTML element contains style information for a document, or part of a document. It contains CSS, which is applied to the contents of the document containing the <style> element.
If you want to remove a specific style tag, you can add a class (or id) to it and then use remove() to remove that class.
The <style> tag in HTML helps us to modify our text, viewed in the page. This modification includes changing font size, font family, font color etc. Not only the texts but also we can change the style of a body ar part of a page.
It is an HTML comment ensuring a browser will not interpret the CSS within the style
element as HTML to display.
Mostly used for (very) old browsers that did not support CSS at all or did not know it ignore the content within the element.
This was also commonly done with inline javascript.
"Is it to exclude certain browsers which will see it as a comment?"
Yes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With