HTML:我们真的需要不同的 DocType 吗?

发布于 2024-08-15 08:04:29 字数 180 浏览 10 评论 0原文

为什么 w3c 有不同文档类型的约定..?相反,他们可以只推荐一种文档类型(比如松散类型……因为它容易出现更少的愚蠢错误),并将其标准化到所有浏览器(包括 mob 和 PDA 中的浏览器)..
< br>我在任何教程中都还没有得到任何令人满意的答案..我一直在阅读“这些不同的文档类型有何不同”,但我想知道我们真的需要它吗???

why w3c has the conventions of different Doc-types .. ? Instead they could have recommended only one Doc-type (say loose type.. as it would prone to less number of SILLY errors) and would have standardized it to all browsers (including the ones in mob and PDAs) ..

I haven't got any satisfying answer in any tutorial yet .. I have been reading "how these different Doc-types differ in" but I want to know do we really need it ???

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

猫性小仙女 2024-08-22 08:04:29

这就是 HTML5 的目标:

<!DOCTYPE html>

That's what HTML5 is going to:

<!DOCTYPE html>
偷得浮生 2024-08-22 08:04:29

您可能应该听一下Molly Holzschlag 的 Hansel 分钟。他们与斯科特详细讨论了这个问题。

Molly Holzschlag:所以说真的,当我们考虑 DOCTYPE 时,我们
正在思考一些非常重要的事情
被动的,从来就不是故意的
现在确实如此。

...

所以我们现在有了这个 DOCTYPE 切换
这给现在带来了很大的压力
DOCTYPE 不仅仅是
曾经是。它本质上是一个黑客,
但这是必要的
我认为推动网络发展,这就是原因
我想把那里的一些人叫出来
让人们知道有一些
人们所做的好事。但
这也给我们增添了一层混乱
那个原因。所以有趣的是,当
我们现在比较 DOCTYPE。我们走
到 HTML 5.0,我们看看
DOCTYPE 和 DOCTYPE 很简单
尖括号、感叹号、
小写 HTML 中的 DOCTYPE。那就是
文档类型。没有别的了。

You should probably listen to the Hanselminutes with Molly Holzschlag. They discuss the question with Scott in detail.

Molly Holzschlag: So really, when we think about DOCTYPEs, we're
thinking about something that was very
passive and was never meant to be what
it does now.

...

So we now have this DOCTYPE switching
and this now puts a lot of pressure on
the DOCTYPE to be something more than
it ever was. It is essentially a hack,
but it was one that was necessary to
advance the web I think and that's why
I wanted to call out some people there
to let folks know that there's some
good work that people have done. But
it also added a layer of confusion for
that reason. So it's interesting when
we compare the DOCTYPEs now. We go
over to HTML 5.0 and we look at the
DOCTYPE and the DOCTYPE is simply
angle bracket, exclamation point,
DOCTYPE in lowercase HTML. That is the
DOCTYPE. There's nothing else.

清旖 2024-08-22 08:04:29

旧的文档类型(HTML 5 之前的版本)是 SGML 中的标准化机制,用于嵌入版本和验证信息。如果您使用功能齐全的 SGML 工作流程,它们将为自动处理文件提供很大的可能性。

在这种情况下,HTML 4/XHTML 1 的不同 DOCTYPES 在当时(10 年前)是一个很好的主意。他们允许作者说:“哦,我有一个旧页面,我必须使用这个和那个标签。”或“是的,我使用最新、最干净的标记。我知道我在做什么。”

为什么要使用“公共标识符”之类的东西?好处的一个例子是:它允许在本地存储(并在以后重新分配)任何 HTML 文件的 DTD,并且让您即使在没有 Internet 访问的情况下也可以验证它。 (请记住:SGML 在 80 年代已标准化。)

The old doctypes (pre-HTML 5) are standardized mechanisms in SGML to embed version and validation information. If you use a full-featured SGML workflow, they offer great possibilities to automatically process the file.

In this context the different DOCTYPES of HTML 4/XHTML 1 were then (10 years ago) quite a nice idea. They allowed the authors to say: "Oh, I've an old page, and I'm bound to use this and that tag." or "Yes, I use the newest and cleanest markup out there. I know what I'm doing."

Why this "public identifier" stuff and so? One example of the benefit: It allows to store locally (and re-assign later) the DTD of any HTML file and let's you validate it even without Internet access. (Remember: SGML was standardized in the 80's.)

窗影残 2024-08-22 08:04:29

当前的标准每种语言有 3 个 Doctype,每个都有自己的位置:

  • Frameset — 我正在使用框架
  • Transitional — 这个标准在 90 年代中期出现,我还没有准备好使用 CSS
  • Strict — CSS 已经准备好了

The current standards have three Doctypes per language, each has their own place:

  • Frameset — I'm using frames
  • Transitional — This standard came out in the mid-90s and I'm not ready to use CSS yet
  • Strict — CSS is ready
月棠 2024-08-22 08:04:29

嗯,诸如文档类型之类的标准的演变始终是委员会坐在一起制定标准的过程;实际执行标准;标准的错误和失败变得明显;委员会制定了一个新的、改进的标准,但无法从头开始,因为必须保留向后兼容性。因此,引入了修复和解决方法,以便可以在不破坏旧标准的情况下使用新标准。

很多愚蠢的事情都是这样发展的。

正如其他答案所指出的,HTML 5 承诺在这方面做出一些改进。

Well, the evolution of a standard such as doctypes is always a process of committees sitting together and working out a standard; the real word implementing the standard; errors and failures of the standard becoming visible; and the committee working out a new, improved standard, but not being able to start from scratch because backwards compatibility must be retained. So, fixes and workarounds are introduced so that the new standard can be used without breaking the old one.

A lot of silly things have developed that way.

As the other answers point out, HTML 5, though, promises some improvement on that front.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文