You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

VS Code中已废弃HTML属性自动补全功能开启方法求助

解决HTML废弃属性自动补全问题

方法一:自定义HTML数据文件

VS Code默认的HTML语言服务未包含这类废弃属性的补全提示,你可以通过自定义数据文件手动添加:

  1. 在项目根目录创建html-custom-data.json文件,内容如下:
{
  "version": 1.1,
  "tags": [
    {
      "name": "table",
      "attributes": [
        {
          "name": "cellpadding",
          "description": "单元格内容与边框的间距(已废弃,建议用CSS padding替代)",
          "valueSets": ["number"]
        },
        {
          "name": "cellspacing",
          "description": "单元格之间的间距(已废弃,建议用CSS border-spacing替代)",
          "valueSets": ["number"]
        }
      ]
    },
    {
      "name": "td",
      "attributes": [
        {
          "name": "height",
          "description": "单元格高度(已废弃,建议用CSS height替代)",
          "valueSets": ["length"]
        },
        {
          "name": "width",
          "description": "单元格宽度(已废弃,建议用CSS width替代)",
          "valueSets": ["length"]
        }
      ]
    }
  ]
}
  1. 在VS Code的settings.json中添加配置,指向这个自定义文件:
"html.customData": ["./html-custom-data.json"]

重启VS Code后,输入<table>或<td>时就能看到这些废弃属性的补全提示。

方法二:检查基础配置是否正确

确保你的HTML相关配置没有禁用补全功能,在settings.json中确认:

"[html]": {
  "editor.suggest.enabled": true,
  "editor.suggest.showDeprecated": true,
  "editor.showDeprecated": true
}

若之前editor.suggest.enabled被设为false,即使开启废弃属性显示也不会触发补全。

内容的提问来源于stack exchange,提问作者Misha Konoval

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.22 19:55:55