Hu bojun explained the reasons for invalid comments in CSS and Hu bojun explained the failure of css.

Source: Internet
Author: User
Tags html comment

Hu bojun explained the reasons for invalid comments in CSS and Hu bojun explained the failure of css.
In a webpage automatically generated by Dreamweaver, style sheets in the head are usually in the following format:
<Style type = "text/css">
<! --


......
-->

</Style>

An html annotation is automatically added at the beginning and end of the style sheet: <! -- And -->. If you think this is the same as the html comment mark, writing the comment will invalidate the style sheet definition.

When <! -- After adding the following words, all the following content will be ignored until </style> ends.

This is a low-level error that is easily overlooked. The reason is simple. The comments Syntax of CSS is:

/*......*/

Instead:

<! --
......

-->

The latter is the simplified html syntax. The two are not the same thing.

So, why is there such an html annotation tag in the automatically generated style?

This is to be compatible with earlier browsers. The old browser does not support styles. Therefore, the content of the style sheet is displayed on the page when you encounter styles. However, in earlier versions, browsers recognize the html annotation tag, so the tag is added.

This part of the content will be ignored as a comment, and the style sheet will not be displayed on the page.

Browsers that support style will ignore <! -- Mark to use the style sheet normally. This is probably one of the reasons why the notes in the style sheet should be marked.


Conclusion: If you use <! --> This annotation may cause errors in css styles. Replace it.



Welcome to read my full set of online Java teaching UHD video:

Http://v.youku.com/v_show/id_XODQ1NjU0NDc2.html this is one of the video connection, you can drag to the youku video below, subscribe to my account, because later I will have more videos available for free

Baidu search: Enter the Fcs_D code farmer, or enter "Hu bojun" to view many of my videos.

Or add my ID: fcsboy. I can send you a notification in time.

QQ group: 237053693

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.