This article mainly introduces the use of character encoding declarations in CSS. It has certain reference value. Now I share it with everyone. Friends in need can refer to it
@charset “utf-8”; The page encoding used to indicate the CSS file in the CSS file is UTF-8. Below we will use this as an example to summarize some points to note when using character encoding declarations in CSS. Friends in need can refer to
many People will define @charset "utf-8" when styling; some people don't define it. The function of this attribute is actually to forcefully declare your CSS document type attribute. Using it correctly will lock your document type to yours. I want it, but many people often do not define this attribute. I have not come to see how to define it correctly.
To define this attribute, it must first appear in the first line of the document in order for the attribute to take effect:
@charset "utf-8"; .test{ margin-top: 30px; }
The following writing methods are errors and invalid writing methods:
Comments are written in the statement The previous one is invalid:
/* test test */ @charset "utf-8"; .test{ margin-top: 30px; }
2. The declaration must be on the first line, otherwise it is invalid:
@charset "utf-8"; .test{ margin-top: 30px; } 3.声明前面不能有空格: @charset "utf-8"; .test{ margin-top: 30px; }
4. The declaration document type format must use double quotes, single quotes are invalid:
@charset 'utf-8'; .test{ margin-top: 30px; }
The above is the entire content of this article. I hope it will be helpful to everyone's study. For more related content, please pay attention to the PHP Chinese website!
Related recommendations:
About the application of CSS pseudo-elements
The above is the detailed content of The use of character encoding declarations in CSS. For more information, please follow other related articles on the PHP Chinese website!