CSS prohibition symbols
CSS Prohibited Symbols
CSS is a language used to describe web page styles. Through CSS, we can control the style, layout, and other properties of elements on a web page. In CSS, some symbols are prohibited. These symbols can cause errors in style parsing and affect the display quality of web pages. This article will detail the prohibited symbols in CSS and their impact on style.
1. @ Character
In CSS, the @ character is a special symbol that indicates specific instructions or rules, known as “at rules.” The @ character is commonly used to include external style files, define fonts, and more. However, in standard style rules, the @ character is prohibited because it invalidates the entire style rule.
For example, the following code is incorrect:
@charset "UTF-8";
body {
font-size: 16px;
}
In the above code, the @charset rule is invalid and will not work in browsers.
2. Double slashes (//)
Double slashes (//) are treated as comment characters in CSS, used to comment out a line. However, double slashes are prohibited in style rules because browsers interpret the content following the double slashes as a comment when parsing CSS, invalidating the entire style rule.
For example, the following code is incorrect:
p {
color: blue;
// font-weight: bold;
}
In the above code, the font-weight property following the double slashes will not work.
3. Double quotes (“)
Double quotes (“) are commonly used in CSS to define string values, such as the font-family property. However, double quotes are prohibited within style rules because they can cause parsing errors.
For example, the following code is incorrect:
h1 {
font-family: "Arial";
}
In the above code, double quotes will cause the style rule to fail.
4. Single Quotes (‘)
Like double quotes, single quotes (‘) are used to define string values in CSS. Single quotes are also prohibited in style rules.
For example, the following code is incorrect:
a {
background-image: url('https://coder-cafe.com/wp-content/uploads/2025/09/image.jpg');
}
In the above code, single quotes will cause a parsing error.
5. Less-Than and Greater-Than Signs (< and >)
The less-than (<) and greater-than (>) signs are commonly used in HTML tags to indicate the start and end of an element. In CSS style rules, these two symbols are prohibited.
p:before {
content: "<Hello>";
}
In the above code, the less-than and greater-than signs will cause the style to be invalid.
6. Pound Sign (#)
In CSS, the pound sign (#) is often used to represent an ID selector, used to select an element with a specified ID on the page. The pound sign is prohibited in style rules.
#footer {
background-color: blue;
}
In the above code, the pound sign will cause the style to be invalid.
7. Double Colon (::)
The double colon (::) is often used in pseudo-element selectors to select a specific part of an element. Double colons are prohibited in style rules.
p::first-letter {
font-size: 20px;
}
In the above code, the double colon will cause the style to be invalid.
Summary
In CSS style rules, several symbols are prohibited, including the @ character, double slashes, double quotes, single quotes, the less-than sign, the greater-than sign, the pound sign, and double colons. These symbols can cause style parsing errors and affect the display quality of web pages. Therefore, when writing CSS styles, you should avoid using these prohibited symbols to ensure correct style parsing.