Home > Backend Development > PHP Tutorial > The use of character encoding declarations in CSS

The use of character encoding declarations in CSS

不言
Release: 2023-04-01 17:04:02
Original
1543 people have browsed it

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;   
}
Copy after login

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;   
}
Copy after login

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;   
}
Copy after login

4. The declaration document type format must use double quotes, single quotes are invalid:

@charset 'utf-8';   
.test{   
    margin-top: 30px;   
}
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template