开发者

What are the implications of using custom tags in HTML, or What are the advantages of not using custom tags?

开发者 https://www.devze.com 2023-03-10 19:07 出处:网络
I am only talking about custom tags which has a start tag and an end tag. For example: <toy>Content</toy>

I am only talking about custom tags which has a start tag and an end tag.

For example:

<toy>Content</toy>

(And if I really need to support old browsers, I will have the shiv in)

I want to know what's the advantage of not using custom tags? or what are the implications of using them?

Don't tell me it's bad because it does not follow standards. Tell me what will i lose from not following this standard. Similarly, don't tell me it's good because it follows standards. Tell me what can i gain from following this standard.

Following standards is just a means to an end, and the end is to work in all browsers. So far, all browsers are rendering it in the same way, in the same behavior, even though there are no specifications standardizing this standard. Therefore, an argument like "if we follow standards it will work in more/all browsers" does开发者_高级运维n't work simply because it is now already working in all browsers.

To be sure, an argument like "we may have to edit it in the future" is not convincing at all because all evidences show otherwise. (look at what happened to the advocates of draconian)

===

Related threads (but does not answer this question): What's stopping me from using arbitrary tags in HTML?


You're basically talking about XMLish behavior. Most browsers support this feature, this is why you can use HTML5 tags with the proper styling. Usually browsers treat unknown tags as inline elements and you should style it to fix your needs.

I think the reason that you shouldn't pepper your page with your own custom markup is context. A tag like <header> has a distinct meaning that is well understood by software (crawlers, readers). But a tag like <toy> has no context attached to it. It only makes meaning to you.

A web page isn't supposed to be a standalone element. It's part of a bigger whole. While a tag such as <toy> may make perfect sense to you, it won't mean anything to a bot or other software. This means that machines won't be able to understand your page as well as other pages that use better markup. This is a bad thing since this would effect how your page is ranked or indexed or consumed.

0

精彩评论

暂无评论...
验证码 换一张
取 消