Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the usage of comment notations in style tag?

Tags:

html

css

For example :

<style type="text/css">
    <!--
    #map{ width:500px;height:500px;float:left }
    -->
</style>

What is the usage of <!-- --> ?

like image 708
Cheung Avatar asked Dec 15 '10 07:12

Cheung


People also ask

How do you comment with style tags?

Like most languages, CSS allows the users to add comments in the stylesheet. Comments in CSS can be added by using the /* tag, which is then closed off by using */ . Note: Code that is commented out is not used to style the page. This technique can be used to add both single and multi-line comments.

How do you comment in style in HTML?

The /* */ comment syntax is used for both single and multiline comments. There is no other way to specify comments in external style sheets.

Which symbol is used in comment tag?

HTML Comment Tag Notice that there is an exclamation point (!) in the start tag, but not in the end tag. Note: Comments are not displayed by the browser, but they can help document your HTML source code.

What symbols are used as comments in HTML?

An HTML comment begins with <! –– and the comment closes with ––> . HTML comments are visible to anyone that views the page source code, but are not rendered when the HTML document is rendered by a browser.


1 Answers

It stops Netscape 2 era browsers, which don't recognize the <style> element, from rendering the content as text (since they start to render the content, but it is a comment, so it isn't rendered).

This is described in the HTML specification.

Entirely worthless today, but people keep adding them without understanding them in a cargo cult mentality.

like image 75
Quentin Avatar answered Oct 13 '22 15:10

Quentin