微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

VS Code - 为什么 vscode 不显示 html 标签属性

如何解决VS Code - 为什么 vscode 不显示 html 标签属性

我使用 VS Code 进行 HTML 编辑,但是当我输入标签时,它不显示属性,甚至当我添加我想要的属性时,它也无法识别它。 我做了以下事情,但没有一个奏效:

1-我安装了相关的扩展(HTML CSS 支持、HTML 片段、HTML 样板等)。 2-添加标签后,按 Ctrl+Space。 3-重新启动我的机器。 4-重新安装VS代码

(我在下面输入了 css、html 代码,我的 css 文件名称是“style post.css”,它在我的 HTML 文件所在的文件夹中)。

我尽力了,如果有人能指导我,我会很高兴。

h2.head1{
    color:red ;
}
<!DOCTYPE html>
<html lang="en">
<head>
    <Meta charset="UTF-8">
    <title>Post</title>
    <link rel="stylesheet" href="style_post.css">
</head>
<body>
    <h1> Scrambled Eggs </h1>
    <p>
    eggs are one of my favorite foods.here is recipe for delicIoUsly rich scrambled eggs.<br>
    </p>
    <h2 class:"head1">Ingredients</h2>
    
    <ul>
        <li>
        2eggs
        </li><li>
        1 tbs butter
        </li><li>
        2 tbs cream
        </li>
    </ul>
    
    <h2>Method</h2>
    
    <ol>
        <li>
        Melt butter in a frying pan over a medium heat.
        </li><li>
        Gently mix the eggs and cream in the bowl.
        </li><li>
        once bottle has melt add cream and eggs.
        </li><li>
        Using the spatula fold the eggs from the edge of the pan to the center every 20 secend(as if you are making an omelette)
        </li><li>
        When the eggs are still moist remove from the heat(it will continue to cook on the plate until served)
        </li>
    </ol>
</body>
</html>

解决方法

您要么打错了字,要么必须查找如何在 HTML 中设置属性:您使用以下语法执行此操作:attribute="value" 而不是 :

所以在你的情况下你应该使用 class="head1"

h2.head1{
    color:red ;
}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Post</title>
    <link rel="stylesheet" href="style_post.css">
</head>
<body>
    <h1> Scrambled Eggs </h1>
    <p>
    eggs are one of my favorite foods.here is recipe for deliciously rich scrambled eggs.<br>
    </p>
    <h2 class="head1">Ingredients</h2>
    
    <ul>
        <li>
        2eggs
        </li><li>
        1 tbs butter
        </li><li>
        2 tbs cream
        </li>
    </ul>
    
    <h2>Method</h2>
    
    <ol>
        <li>
        Melt butter in a frying pan over a medium heat.
        </li><li>
        Gently mix the eggs and cream in the bowl.
        </li><li>
        once bottle has melt add cream and eggs.
        </li><li>
        Using the spatula fold the eggs from the edge of the pan to the center every 20 secend(as if you are making an omelette)
        </li><li>
        When the eggs are still moist remove from the heat(it will continue to cook on the plate until served)
        </li>
    </ol>
</body>
</html>

,

感谢用户:已克隆 我能够找到问题的第二部分的答案,即“为什么 vscode 不会自动打开某些带有其属性名称的标签”。

我说也许有人有和我类似的问题,可以帮助他/她:)

如图所示,我们要选择页面右下角的html,而我的问题是语言是django html。

enter image description here

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。