How to add custom HTML Tags to Visual Studio and Avoid Squiggly Lines

旧时模样 提交于 2019-12-19 16:53:54

问题


I'm using Visual Studio 2013 to create raw HTML pages (i.e. index.html).

In my HTML I am implementing custom HTML tags. As such, Visual Studio underlines my custom tags with squiggly lines (due to the warning of "Unknown element ...").

In hopes to get rid of the squigglies, I added my custom tags to the list of "Tag Specific Options" via Tools > Options > Text Editor > HTML (Web Forms) > Formatting > Tag Specific Options. However, the squiggly lines persist.

Is there a way to inform VS2013 that my custom HTML tags are valid (i.e. keep VS2013 from underlining my custom tags with squigglies)?


回答1:


Visual Studio 2013 Update 4 removes the validation in .html files, but not in .aspx files.

Support for custom elements, polymer-elements and attributes

We no longer validate unknown attributers for custom elements as there will be many custom made tags in different frameworks. So there will no longer be squiggles under the unknown elements.

— Announcing new Web Features in Visual Studio 2013 Update 4 RC

Download Visual Studio 2013 Update 4.

Validation is only removed in the HTML editor, not the HTML (Web Forms) editor. This means that, by default, .html files will not have custom element validation, but .aspx pages will. If, like me, you don't think this makes sense, show your support by voting for custom elements in .aspx files.




回答2:


Hmm... what are you trying to accomplish? Keep in mind that if you could somehow make visual studio ignore the unknown element, that's no guarantee browsers looking at your page will be able to translate the element too.

Are your pages HTML5? if so you've got a shot at making it work. but you'll have to define it in client code. Here is source.

But most browsers don't support it yet! look at here elements.

In the case of making Visual Studio recognise the tags you could take this approach:

1) Go to: Tools > Options > Text Editor > HTML (Web Forms) > Formatting 2) Press "Tag Specific Options" 3) Select "Client HTML Tags" in the new window's treeview 4) Press "New Tag" below the treeview to add a new tag



来源:https://stackoverflow.com/questions/25715897/how-to-add-custom-html-tags-to-visual-studio-and-avoid-squiggly-lines

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!