在 HTML 中使用自定义标签有什么含义,或者不使用自定义标签有什么好处? [英] What are the implications of using custom tags in HTML, or What are the advantages of not using custom tags?

查看:47
本文介绍了在 HTML 中使用自定义标签有什么含义,或者不使用自定义标签有什么好处?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是在谈论具有开始标签和结束标签的自定义标签.

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

例如:

<toy>Content</toy>

(如果我真的需要支持旧浏览器,我将拥有 shiv in)

(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" doesn'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)

===

相关线程(但不回答此问题):是什么阻止我在 HTML 中使用任意标签?

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

推荐答案

您基本上是在谈论 XMLish 行为.大多数浏览器都支持此功能,这就是您可以使用具有正确样式的 HTML5 标签的原因.通常浏览器将未知标签视为内联元素,您应该对其进行样式设置以解决您的需求.

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.

这篇关于在 HTML 中使用自定义标签有什么含义,或者不使用自定义标签有什么好处?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆