问题
I would like to use custom attribute inside H tag for example
<h3 mydata="1">header</h3>
Is this style is good for SEO ?
Thanks
回答1:
This attribute will cause your HTML to stop validating because mydata
is not a recognized attribute for the HTML DOCTYPE.
Instead, use data-
attributes to store data. These are not parsed by search engines and have no effect on the SEO value of your page.
For more information, see: http://www.w3.org/TR/html5/elements.html#embedding-custom-non-visible-data-with-the-data-attributes
回答2:
Im not sure about SEO, but you should always do it in the format:
data-[attribute]
this is the prescribed "HTML5" way of doing custom data attributes and it works on non-html5 browsers. It also is useful when getting data using jQuery -> $(selector).data()
.
回答3:
If you want to store data in attributes then check-out HTML5's data-attributes
: https://developer.mozilla.org/en/HTML/Global_attributes#attr-data-*
You can safely use data-attributes
as far as SEO is concerned.
Your attribute would look like this:
<h3 data-mydata="1">header</h3>
回答4:
"mydata" wouldn't be valid HTML. So no, not a good idea.
Use data-attributes instead.
回答5:
SHORT Answer YES, is valid SEO. SEO is all about search engines friendly URL's.
http://en.wikipedia.org/wiki/SEO
Anyways your HTML will not be valid. Use data-attribute instead, as suggested above. If you're a picky HTML developer as I am, you can always validate your HTML using this tool:
http://validator.w3.org/
来源:https://stackoverflow.com/questions/8649419/seo-and-h-tag-with-custom-attribute