How to add custom HTML Tags to Visual Studio and A

2019-02-21 20:14发布

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)?

2条回答
成全新的幸福
2楼-- · 2019-02-21 20:19

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

查看更多
我欲成王,谁敢阻挡
3楼-- · 2019-02-21 20:31

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.

查看更多
登录 后发表回答