在外部样式表开始时报告CSS语法错误的Firebug

时间:2022-03-27 22:41:43

Firebug complains about a syntax error in one of my external CSS files and always blames the first line: SyntaxError: syntax error

Firebug在我的一个外部CSS文件中抱怨语法错误,并且总是抱怨第一行:SyntaxError:语法错误。

For testing purposes I tried to comment out and remove the first rule completely, but the error is still displayed for the next rule. All style sheets in the file are ignored.

出于测试目的,我试图注释掉第一个规则并完全删除它,但是下一个规则仍然显示错误。文件中的所有样式表将被忽略。

在外部样式表开始时报告CSS语法错误的Firebug

1 个解决方案

#1


12  

Actually this is a JavaScript syntax error, not a CSS problem. This happens when absent-mindedly copy-pasting HTML tags and including a CSS file using a script tag. D'oh!

实际上这是一个JavaScript语法错误,而不是CSS问题。当心不在焉地复制HTML标记并使用脚本标记包含CSS文件时,就会发生这种情况。分析!

Actually, the browser tries to parse the CSS content as JavaScript, which of course does not work. The solution is simple:

实际上,浏览器试图将CSS内容解析为JavaScript,这当然不起作用。解决方法很简单:

<script src="style.css"></script> <!-- won't work -->
<link rel="stylesheet" type="text/css" href="style.css"/> <!-- better :) -->

#1


12  

Actually this is a JavaScript syntax error, not a CSS problem. This happens when absent-mindedly copy-pasting HTML tags and including a CSS file using a script tag. D'oh!

实际上这是一个JavaScript语法错误,而不是CSS问题。当心不在焉地复制HTML标记并使用脚本标记包含CSS文件时,就会发生这种情况。分析!

Actually, the browser tries to parse the CSS content as JavaScript, which of course does not work. The solution is simple:

实际上,浏览器试图将CSS内容解析为JavaScript,这当然不起作用。解决方法很简单:

<script src="style.css"></script> <!-- won't work -->
<link rel="stylesheet" type="text/css" href="style.css"/> <!-- better :) -->