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:
- Open VSCode settings.
- Search for "html.validate.styles".
- Set its value to false.
Disabling HTML validation styles will prevent VSCode from attempting to validate CSS within Go templates, resolving the errors.
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