CSS错误:规则或选择器处应为,{应为



我试图在Visual Studio code上运行此代码,但遇到了以下错误:

在Ln1 Col1、Ln7 Col1和Ln50 Col1 处预期的规则或选择器

{预期在Ln2 Col1,Ln51 Col 1

我试着在W3Schools上运行这些,它们运行得很好。我该如何解决这个问题?这是代码,谢谢!

<!DOCTYPE html>
<html>
<head>
<style>
body {
background-color: white;
}
/* Text Display */
h1 {
font-family: georgia, "Times New Roman", Times, serif;
color: black; /* Set text color to black */
text-align: center;
}
#p1 {
font-family: Arial, Helvetica, sans-serif;
color: blue; /* Set text color to blue */
text-align: center;  
}
.center {
font-family: Arial, Helvetica, sans-serif;
color: green; /* Set text color to green */
text-align: center;
}
/* unvisited link */
a:link {
color: blueviolet;
}

/* visited link */
a:visited {
color: gray;
}

/* mouse over link */
a:hover {
color: blue;
font-weight: bold;
}

/* selected link */
a:active {
color: blue;
}
</style>
</head>
<body>
<h1>Welcome!</h1>
<h2 id="p1">Enjoy numerous movie reviews and recommendations here.</h2>
<h3 class="center">Featured movie of the week:</h3>
<p><b><a href="default.asp" target="_blank">Everything Everywhere All at Once</a></b></p>

</body>
</html>

在Visual Studio代码右下角,将"语言模式"从CSS更改为HTML。

有时您的编辑器可能会意外地在的某个位置放置额外的字符

要查看这些,你可以参考这个空白

否则,将整个代码复制到窗口中的普通记事本中,并将其粘贴回VS代码

或者你可以使用Notepad++查看所有字符,然后删除它们

否则,复制粘贴你的代码,一次一个样式,你可以缩小问题

最新更新