HTML5 和格式良好

发布于 2024-09-16 21:17:07 字数 677 浏览 10 评论 0原文

我正在研究 HTML5,我很困惑为什么它在格式良好方面如此容易。

<div id="main">  
<DIV ID="main">  
<DIV id=main>

都是有效的并产生相同的结果。我认为通过 XHTML,我们可以免费转向符合 XML 的代码(我不将结束标签算作成​​本!)。现在 HTML5 规范看起来是由懒惰的程序员和/或无政府主义者编写的。结果是,从 HTML5 开始,我们就有了两个版本:HTML5 和符合 XML 的 XHTML5。如果 C 突然允许您通过以下方式编写 for 构造,您会认为它是一种资产吗?

for(i = 0; i < 10; i++) {  
for(i = o; i < 1o; i++) {  // you can use "o" instead of "0"  
for(i = 0, i < 10, i++) {  // commas instead of semicolons are alright!  

坦率地说,作为一名 XHTML 编码员,我觉得 HTML5 规范有点侮辱我。
瓦迪亚认为?
史蒂文

编辑:
注意“wadya”:作为客户,您会接受写有“wadya”而不是“What do you”的信件吗? :-)

I'm looking into HTML5 and I'm puzzled why it goes so easy on well-formedness.

<div id="main">  
<DIV ID="main">  
<DIV id=main>

are all valid and produce the same result. I thought with XHTML we moved to XML compliant code at no cost (I don't count closing tags as a cost!). Now the HTML5 spec looks to be written by lazy coders and/or anarchists. The result is that from the start of HTML5 we have two versions: HTML5 and the XML compliant XHTML5. Would you consider it an asset if C would suddenly allow you to write a for construct in the following ways?

for(i = 0; i < 10; i++) {  
for(i = o; i < 1o; i++) {  // you can use "o" instead of "0"  
for(i = 0, i < 10, i++) {  // commas instead of semicolons are alright!  

Frankly, as an XHTML coder since many moons I feel a bit insulted by the HTML5 spec.
Wadya think?
Steven

edit:
Mind the "wadya": would you as a customer accept a letter with "wadya" written instead of "What do you"? :-)

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

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

发布评论

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

评论(5

水波映月 2024-09-23 21:17:07

HTML 5不像是 XHTML 那样的 XML 方言。

HTML 之所以如此流行,是因为它能够容忍错误,因此几乎任何人都可以编写 HTML 页面。

XHTML 使其变得更加困难,并且没有得到广泛采用。与此同时,HTML/XHTML的进一步发展陷入停滞,因此成立了一个行业团体,WHATWG开始研究下一代 HTML 并决定恢复到 HTML 5 的非 XML 标准。

由于 XML 比 HTML 更严格,因此您始终可以将 HTML 编写为兼容 XML。确保属性采用小写,使用值分隔符,元素具有结束标记,并在需要时使用正确的 XML 转义。

HTML 5 is not an XML dialect like XHTML is.

What made HTML so popular was the fact that it tolerated mistakes, so just about anyone could write an HTML page.

XHTML made it much more difficult and it didn't get widely adopted. At the same time, further development of HTML/XHTML stagnated, so an industry group formed up, the WHATWG who started work on the next generation of HTML and decided to revert to a non XML standard for HTML 5.

Since XML is stricter than HTML, you can always write your HTML to be XML compliant. Make sure attributes are in lower case, use value delimiters, elements have closing tags and use correct XML escaping where needed.

丢了幸福的猪 2024-09-23 21:17:07

HTML 从来就不是为了传达媒体,因此也不是为了
用于任何类型的营销或推销。 HTML 的目的只是
传达文本并提供某种描述性结构
它所描述的文字。最初使用 HTML 的人教授和
需要能够描述他们的通信的科学家
允许有更多的深度、换行符和引号。换句话说 HTML
仅旨在成为一种文档存储机制。记住
当时还没有网络浏览器。

HTML 最初是随着网络浏览器的发布而流行起来的。
最初 Web 浏览器只是提供方便的 GUI 的文本解析器
用于导航文档之间的超链接,但这发生了变化
几乎立即。当时还没有真正的标准
HTML。有标签列表和机制描述
最初是为 HTML 创建的,加上对 SGML 的理解,
创建 HTML 解析器所需的一切。

随着 Web 浏览器的出现,迫切需要以 HTML 方式扩展 HTML
从来没有打算。正是在这一点上,发明者和原创者
用户完全失去了对网络的控制。添加了标签,例如
中心和字体,表格成为放置的主要机制
把事情写在页面上而不是描述数据。提供网络浏览器
与 HTML 的意图完全正交的媒体需求。
营销人员本质上是非常在乎外表的
和沟通的表达性,不要在乎
使这种通信成为可能的技术。结果解析器
变得更加宽松,以适应无能的人。你必须明白
HTML 已经很宽松了,因为没有标准的解析规则
而SGML,由于非常迟钝,鼓励了外面宽松的本性
解析指令标签。

并不是说这些早期的技术先驱是愚蠢的,尽管
很容易反驳,他们只是有其他优先事项。当
网络成为主流,人们立即痴迷于征服特定的领域
这种新媒体的商业利基。所有成本都被推向
营销、市场份额、流量获取和品牌知名度。许多
今天的网络企业以类似的议程运作,但今天的网络是
不公平的比较。在 90 年代,营销才是最重要的
技术成本完全被忽略了。这个问题是如此普遍
投资的激增如此之大,完全不顾一切
经济的理性规则。这就是为什么发生了内爆。这
只有那些在这场危机中幸存下来的网络企业才面临着
他们的技术成本是预先支付的,或者是那些引导投资资金的人
投入技术费用而不是额外的营销费用。

http://en.wikipedia.org/wiki/Dot-com_bubble

崩溃后的事情改变了。考虑这次崩溃是个好时机,因为
尽管这完全是由糟糕的商业决策驱动的,但愚蠢的
投资和非理性经济有积极的技术
幕后正在发生的事态发展。网络的创始人是
完全意识到他们已经失去了对技术的所有控制。
他们试图解决这个问题,并通过创建
万维网联盟 (W3C)。他们邀请了专家和软件
企业参与。虽然解决了很多技术
由营销驱动动机引入网络的问题是
因为如果语言是正确的,许多未来的问题都可以避免
按照商定的标准实施。那是在
这次是 HTML 2(HTML 的第一个标准形式)、HTML 3 和
HTML 4 已编写。

与此同时,W3C 也开始了 XML 方面的工作,但它从未打算
是 HTML 的替代品。 XML 的诞生是因为 SGML 过于复杂。一个
需要基于类似规则的简单语法。 XML 立即
被营销人员否定,立即受到数据赞扬
Microsoft 和 IBM 的传播者。因为围绕 XML 的圣战是
与此类问题相比,微不足道、微不足道且短暂
困扰 HTML XML 的发展如火箭般飞速发展。几乎
XML 形成后,XML Schema 的第一个版本立即发布
形成。

XML Schema 是一项非凡的工作,大多数人要么选择
忽视或视为理所当然。用于访问的抽象模型
HTML 的结构也基于 XML Schema 进行了标准化,称为
文档对象模型 (DOM)。需要注意的是 DOM
最初由浏览器供应商开发,为
JavaScript 访问 HTML,但 W3C 发布的标准 DOM 已经
与 JavaScript 没有直接关系。很快就显而易见的是
许多困扰 HTML 的技术问题可以通过创建
HTML 的 XML 兼容形式。这称为 XHTML。不幸的是,
从 HTML 到 XHTML 的采用路径是以一种混乱的方式引入的
最终澄清多年后仍未得到广泛理解
发生。

所以,发生了崩溃并导致了这段经济崩溃
有一些奇妙的技术发展。最终来源
技术腐败的网络浏览器终于​​才刚刚开始
围绕采用许多出色的技术解决方案进行创新
在 W3C 上梦想,但随着崩溃而来的是几乎完全的损失
浏览器供应商的开发动机。这时有
实际上只有 Netscape、IE 和 Opera。 Opera 不是自由软件,
因此它从未被广泛采用,并且 Netscape 也破产了。这
基本上只剩下 IE 了,微软把他们所有的开发者都拉走了
IE。多年后,当竞争出现时,IE 的开发将会复苏
起源于 Firefox 和 Opera 采用免费许可时。

大约在浏览器重新焕发活力的同时,W3C 也成立了。
继续推进 XHTML2 的开发。 XHTML2 是一个雄心勃勃的
项目并且与 XHTML1 无关,这造成了很多混乱。
W3C 试图解决与 HTML 相关的技术问题
已经被允许长期恶化,他们的意图是正确的
和固体。不幸的是,XHTML2 中存在一些争议
工作组。失败的沟通方式和原因的组合
结合不相关的内容从 HTML 过渡到 XHTML
XHTML2的本质及其内讧让人担忧。

导致网络崩溃的营销干扰已经回归
网络崩溃了,但它并没有死。正是在这个时期复兴了
以及。我们不要忘记,营销动机很重要
技术问题。营销动机是即时的
满足。所有类型的 XHTML,尤其是 XHTML2,都是
对即时满足的厌恶。 XHTML2最终会被杀死
发布了一个草稿。这种恐惧和厌恶导致
建立利益一致的独立标准机构
以即时满足的本质推动 HTML 向前发展
愚蠢。这个新组织将自称为 WHATWG,并将承担
营销火炬前行。

WHATWG 很团结,因为他们的动机很简单,即使
他们对这项技术的愿景非常雄心勃勃,主要是为了使其成为可能
开发人员可以更轻松地使事情变得美观、互动并减少
媒体集成的复杂性。 WHATWG 也取得了成功,
因为自崩溃以来网络开始萎缩。数量较少
周围的主要参与者,每个参与者都有一组特定的优先事项
越来越不一致。

网络是一个媒体渠道,其主要业务是广告。
通过广告赚钱的网络企业往往收入显着
比通过商品或服务赚钱的网络企业更大。作为一个
结果网络的优先事项最终将成为优先事项
媒体和广告发行。例如为什么 JavaScript
在浏览器中变得更快?答案是因为谷歌
广告公司将发布一款网络浏览器作为首要任务
处理 JavaScript 的速度明显更快。去竞争其他
浏览器的速度需要提高 20 到 30 倍才能跟上。这是
很重要,因为 JavaScript 是广告的主要手段
指标是衡量的,这是Google收入的基础。

由于 HTML5 是一种营销友好的规范,因此它允许宽松的规范
句法。浏览器供应商花更多钱在经济上是合理的
编写更复杂的解析机制来防止草率的标记,因为
它使媒体的出版得以更快地发展,从而
让广告更深入地渗透。这是经济上合格的
因为现在可用的 5 种主要网络浏览器主要是
由广告收入资助。不幸的是,这只不过是
对于其他想要编写解析器的人来说,成本是有限的或
对以后对结构化数据的任何解释都是有害的。结果是
缺乏对技术的重视以及隐性成本的增加
给定媒介内技术创新的限制。

这就是为什么 HTML 语法仍然很糟糕。唯一的解决办法是
提出一种替代且技术优越的通信媒介
从技术上强调承包市场的去中心化
的担忧。

HTML was never intended to convey media, and therefore never intended
for any kind of marketing or merchandising. HTML was only intended to
convey text and to provide some sort of descriptive structure upon the
text it was describing. The people originally using HTML professors and
scientists who needed the ability to describe their communications in
more depth and line breaks and quotes would allow. In other words HTML
was only intended to be a document storage mechanism. Keep in mind
there were no web browsers at this time.

HTML was first made popular with the release of the web browsers.
Initially web browsers were just text parsers that provided a handy GUI
for navigating the hyperlinking between documents, but this changed
almost immediately. At this time there was still no actual standard for
HTML. There was the list of tags and a description of mechanisms
initially created for HTML, which along with an understand of SGML, was
all that was required to create an HTML parser.

With web browsers came the immediate demand to extend HTML in ways HTML
never intended. It was at this point that the inventors and original
users completely lost control of the web. Tags were added, such as
center and font, and tables became the primary mechanism for laying
things out on a page instead of describing data. Web browsers supplied
a media demand completely orthogonal to the intentions of HTML.
Marketing people, being what they are, care very much for the appearance
and expressive nature of communications and don't give a crap for the
technology which makes such communication possible. As a result parsers
became more lax to accommodate the incompetent. You have to understand
that HTML was already lax because there were no standard parsing rules
and SGML, due to being so very obtuse, encourages a lax nature outside
of parsing instruction tags.

Its not that these early technology pioneers were stupid, although its
easy to argue the contrary, they simply had other priorities. When the
web went mainstream there was an immediate obsession to conquer specific
business niches in this new medium. All costs were driven towards
marketing, market share, traffic acquisition, and brand awareness. Many
web businesses operate today with similar agendas, but today's web is
not a fair comparison. In the 90s marketing was all that mattered and
technology costs were absolutely ignored. The problem was so widespread
and the surge of investment so grand that it completely defied all
rational rules of economics. This is why there was an implosion. The
only web businesses that survived this crash were those that confronted
their technology costs up front or those who channeled investment monies
into technology expenses opposed to additional marketing expense.

http://en.wikipedia.org/wiki/Dot-com_bubble

After the crash things changed. Consider the crash good timing, because
although it was entirely driven by bad business decisions, foolish
investments, and irrational economics there was positive technology
developments going on behind the scenes. The founders of the web were
completely aware that they had lost all control of their technology.
They sought to solve this problem and set things straight by creating
the World Wide Web Consortium (W3C). They invited experts and software
companies to participate. Although solving many of the technology
problems introduced to the web by marketing drivin motivations was a
lost cause many future problems could be avoided if the language were
implemented in accordance with an agreed upon standard. It was during
this time that HTML 2 (the first standard form of HTML), HTML 3, and
HTML 4 were written.

At the same time the W3C also began work on XML, which never intended to
be a HTML replacement. XML was created because SGML was too complex. A
simple syntax based upon similar rules was needed. XML was immediately
written off by marketing people and was immediately praised by data
evangalists at Microsoft and IBM. Because the holy wars around XML were
trivial, insignificant, and short lived compared to such problems
plaguing HTML XML's developement occurred at rocket speed. Almost
immediately after XML was formed the first version of XML Schema was
formed.

XML Schema was an extradinary work that most people either choose to
ignore or take for granted. An abstration model for accessing the
structure of HTML was also standardized based upon XML Schema, know as
the Document Object Model (DOM). It is important to note that the DOM
was initially developed by browser vendors to provide an API for
JavaScript to access HTML, but the standard DOM released by the W3C had
nothing to do with JavaScript directly.It quickly became obvious that
many of technology problems plaguing HTML could be solved by creating an
XML compliant form of HTML. This is called XHTML. Unfortunately, the
path of adoption from HTML to XHTML was introduced in a confused manner
that is still not widely understood years after clarification finally
occurred.

So, there was a crash and leading up to this period of economic collapse
there were some fantastic technology developments. The ultimate source
of technology corruption, the web browsers, were finally just starting
to innovate around adoption of the many fantastic technology solutions
dreamed up at the W3C, but with the crash came an almost complete loss
of development motivation from the browser vendors. At this time there
was only really Netscape, IE, and Opera. Opera was not free software,
so it was never widely adopted, and Netscape went under. This
essentially left only IE and Microsoft pulled all their developers off
IE. Years later development on IE would be revived when competition
arose from Firefox and when Opera adopted free licensing.

About the same time that browsers were coming back to life the W3C was
moving forward with development of XHTML2. XHTML2 was an ambitious
project and was not related to XHTML1, which created much confusion.
The W3C was attempting to solve technology problems associated with HTML
that had been allowed to fester for long and their intentions were valid
and solid. Unfortunately, there was some contention in the XHTML2
working group. The combination of failed communication on how and why
to transition from HTML to XHTML in combination with the unrelated
nature of XHTML2 and its infighting made people worry.

The marketing interference that allowed the web to crash regressed with
the web crash, but it did not die. It was reviving during this period
as well. Let's not forget that marketing motivations give dick about
technology concerns. Marketing motivations are about instant
gratification. All flavors of XHTML, especially XHTML2, were an
abomination to instant gratification. XHTML2 would eventually be killed
for a single draft was published. This fear and disgust lead to the
establishment of separate standards body whose interests were aligned
with moving HTML forward in the nature of instant gratification
silliness. This new group would call itself WHATWG and would carry the
marketing torch forward.

The WHATWG was united, because their motivations were simple even if
their visions of the technology were ambitious, essentially to make it
easier for developers to make things pretty, interactive, and reduce
complexity around media integration. The WHATWG was also successful,
because the web began to contract since the crash. There were fewer
major players around and each had a specific set of priorities that were
more and more inalignment.

The web is a media channel and its primary business is advertising.
Web businesses that make money from advertising tend to be significantly
larger than web businesses that make money from goods or services. As a
result the priorties of the web would eventually become the priorities
of media and advertising distribution. For instance why did JavaScript
become much faster in the browser? The answer is because Google, an
advertising company, made it a priority to release a web browser that
was significantly faster at processing JavaScript. To compete other
browsers would need to become 20 to 30 times faster to keep up. This is
important because JavaScript is the primary means by which advertisement
metrics are measured, which is the basis of Google's revenue.

Since HTML5 is a marketing friendly specification it allows a lax
syntax. Browser vendors are economically justified to spend more money
writing more complex parsing mechanisms against sloppy markup, because
it allows more rapid developement by which media is published so as to
allow deeper penetration of advertising. This is economically qualified
because all of the 5 major web browsers available now are primarily
funded from advertising revenue. Unfortunately, this is nothing but
cost for anybody else that want's to write a parser and is limiting or
harmful to any later interpretation of structured data. The result is
a lack of regard for the technology and the rise of hidden costs with
limits upon technology innovation within the given medium.

This is why HTML syntax continues to be shit. The only solution is to
propose an alternate and technologically superior communication medium
that technologically emphasizes a decentralization of contracting market
concerns.

¢好甜 2024-09-23 21:17:07

规范允许它比禁止它更好,无论如何每个人都会这样做,并且浏览器必须纠正错误。

XHTML 从未真正起飞,尤其是因为 MSIE 从未支持它(通过发送 text/html 内容类型来假装它是 HTML)。

Better that the spec allows it then it forbids it, everyone does it anyway, and browsers have to error correct.

XHTML never really took off, not least because MSIE never supported it (pretending it is HTML by sending a text/html content type not withstanding).

倦话 2024-09-23 21:17:07

对于自然解析来说,首先不需要引号。

关于大小写,HTML元素无论大小写都被保留;例如,您不能定义自己的 DiV 或 Div。

HTML 是一种标记语言,速度和简单性比一致性更重要。

尽管存在争议,但这对搜索引擎来说非常重要。带有引用属性和任何类型错误的文档的处理成本非常高。这很有趣——HTML 文档中引用的示例在引号中包含了“bevil”;也就是说,不使用引号并不是邪恶的。

For natural parsing the quotes aren't necessary in the first place.

Regarding case, HTML elements are reserved regardless of case; for example, you can't define your own DiV or Div.

HTML is a markup language where speed and simplicity is a greater priority than consistency.

While arguable, this matters greatly to search engines; documents with quoted attributes and any kind of error are very expensive to process. It's funny -- the quoted example in HTML docs has 'be evil' in quotes; as to say that, not using quotes is not being evil.

小忆控 2024-09-23 21:17:07

老实说,你的问题本身就有答案。 “我们有两种不同的规格。”每个规范都涉及不同级别的一致性,它们这样做是有原因的。尽管我们可能讨厌“向后兼容性”的概念,但它是我们必须承受的负担,而且 HTML5 在维护它方面比 XHTML5 做得更好。

Honestly, your question answers itself. "We have two different specs." Each spec addresses a different level of conformance, and they do so for a reason. As much as we might loathe the notion of "backwards compatibility," it's a burden we have to bear, and HTML5 is far better at maintaining it than XHTML5 will ever be.

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