Are Non-HTML tags in a HTML document bad for SEO? [closed]

走远了吗. 提交于 2019-12-07 13:51:32

问题


Is it a bad practice have non-HTML tags of the page? I need to use them for internal content processing needs and wonder if there are any troubles with it (SEO for example)?


回答1:


Yes it is bad. Not particularly for SEO but for browsers. You are relying on the browser to ignore your tags and render the page correctly. Since every rendering engine loads a page slightly differently, you have no way of knowing how it will handle your bad html.

Can you wrap them in html comments? Like so:

<!--<not a real tag>-->

The browser and spiders will ignore these but since they are still part of the html, your parser might still be able to read them.

An alternative is to use HTML5's custom data attributes. Your parser should also be able to read these.

W3C also have an experimental custom elements spec. Browser support looks poor at present but this may be of interest in future.




回答2:


Yes, it's bad for browsers (and a little for SEO). Each browser could interpret a random tag on its own way.

If you need to do internal content processing, you can store your data in attributes of your existing HTML tags, with data-* attributes (HTML5 spec.), like this:

<div class="simple-div" data-file="./abc.txt" data-pattern="(.+)"></div>
<a href="javascript:void(0)" data-objID="42">My link!</a>

The HTML document shouldn't store data anyway.




回答3:


I dont know what you want to do specifically, but you could use an invisible div or hidden field with custom data attributes? or even a comment?



来源:https://stackoverflow.com/questions/17923853/are-non-html-tags-in-a-html-document-bad-for-seo

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