"If a worker wants to do his job well, he must first sharpen his tools." - Confucius, "The Analects of Confucius. Lu Linggong"
Front page > Programming > VSCode shows the reason for CSS verification error in Go template

VSCode shows the reason for CSS verification error in Go template

Posted on 2025-04-29
Browse:352

Troubleshooting CSS Errors in VSCode While Editing Go Templates

When utilizing Go's html/template package and writing templates like mypage.tmpl, you may encounter CSS validation errors in VSCode.

For instance, the following code snippet within mypage.tmpl:

Can trigger the following errors:

  • "property value expected css (css-property value expected)"
  • "at-rule or selector expected css (css-rule selector expected)"

These errors occur when trying to utilize {{ }} within the style HTML attribute.

Solution

To resolve this issue, disable HTML validation styles in VSCode settings:

  1. Open VSCode settings.
  2. Search for "html.validate.styles".
  3. Set its value to false.

Why Does VSCode Show CSS Validation Errors in Go Templates?

Disabling HTML validation styles will prevent VSCode from attempting to validate CSS within Go templates, resolving the errors.

Latest tutorial More>

Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.

Copyright© 2022 湘ICP备2022001581号-3