HTML 4和HTML 5的关键区别是什么?

时间:2021-12-14 20:09:35

What are the key differences between HTML4 and HTML5 draft?

HTML4和HTML5草案的关键区别是什么?

Please keep the answers related to changed syntax and added/removed html elements.

请保留与更改语法有关的答案,并添加/删除html元素。

8 个解决方案

#1


185  

HTML5 has several goals which differentiate it from HTML4.

HTML5有几个不同于HTML4的目标。

Consistency in Handling Malformed Documents

The primary one is consistent, defined error handling. As you know, HTML purposely supports 'tag soup', or the ability to write malformed code and have it corrected into a valid document. The problem is that the rules for doing this aren't written down anywhere. When a new browser vendor wants to enter the market, they just have to test malformed documents in various browsers (especially IE) and reverse-engineer their error handling. If they don't, then many pages won't display correctly (estimates place roughly 90% of pages on the net as being at least somewhat malformed).

主要的是一致的、定义好的错误处理。正如您所知道的,HTML有意地支持“标签汤”,即编写畸形代码并将其修改为有效文档的能力。问题是这样做的规则没有写下来。当一个新的浏览器供应商想要进入市场时,他们只需要在不同的浏览器(尤其是IE)中测试格式错误的文档并反向设计他们的错误处理。如果他们不这样做,那么许多页面将无法正确显示(估计大约90%的页面在网络上被认为至少有一些畸形)。

So, HTML5 is attempting to discover and codify this error handling, so that browser developers can all standardize and greatly reduce the time and money required to display things consistently. As well, long in the future after HTML has died as a document format, historians may still want to read our documents, and having a completely defined parsing algorithm will greatly aid this.

因此,HTML5正试图发现并编写这种错误处理,以便浏览器开发人员都能标准化并大大减少持续显示内容所需的时间和金钱。同样,在HTML作为一种文档格式而死后,历史学家可能仍然希望阅读我们的文档,并且拥有一个完全定义的解析算法将极大地帮助这一点。

Better Web Application Features

The secondary goal of HTML5 is to develop the ability of the browser to be an application platform, via HTML, CSS, and Javascript. Many elements have been added directly to the language that are currently (in HTML4) Flash or JS-based hacks, such as <canvas>, <video>, and <audio>. Useful things such as Local Storage (a js-accessible browser-built-in key-value database, for storing information beyond what cookies can hold), new input types such as date for which the browser can expose easy user interface (so that we don't have to use our js-based calendar date-pickers), and browser-supported form validation will make developing web applications much simpler for the developers, and make them much faster for the users (since many things will be supported natively, rather than hacked in via javascript).

HTML5的第二个目标是通过HTML、CSS和Javascript开发浏览器作为应用平台的能力。许多元素被直接添加到当前(在HTML4中)Flash或基于jms的hack语言中,比如

Improved Element Semantics

There are many other smaller efforts taking place in HTML5, such as better-defined semantic roles for existing elements (<strong> and <em> now actually mean something different, and even <b> and <i> have vague semantics that should work well when parsing legacy documents) and adding new elements with useful semantics - <article>, <section>, <header>, <aside>, and <nav> should replace the majority of <div>s used on a web page, making your pages a bit more semantic, but more importantly, easier to read. No more painful scanning to see just what that random </div> is closing - instead you'll have an obvious </header>, or </article>, making the structure of your document much more intuitive.

还有许多其他较小的努力发生在HTML5,增速甚至语义角色等现有元素( <强> 和< em >实际上意味着不同的东西,甚至是< b >和 <我> 模糊语义解析时要做好遗留文档)和添加新元素提供有用的语义—— <文> , <节> 、 <标题> 、< >,和 <导航> 应该取代大部分的< div > s上使用一个web页面,使页面更加语义,但更重要的是,更容易阅读。没有比随机的关闭更痛苦的扫描了——相反,您将有一个明显的,或,使您的文档结构更直观。

#2


41  

From Wikipedia:

从*:

  • New parsing rules oriented towards flexible parsing and compatibility
  • 面向灵活解析和兼容性的新解析规则
  • New elements – section, video, progress, nav, meter, time, aside, canvas
  • 新元素-切片,视频,进度,导航,米,时间,旁白,画布
  • New input attributes – dates and times, email, url
  • 新的输入属性-日期和时间,电子邮件,url
  • New attributes – ping, charset, async
  • 新属性- ping, charset, async
  • Global attributes (that can be applied for every element) – id, tabindex, repeat
  • 全局属性(可以应用于每个元素)- id, tabindex, repeat
  • Deprecated elements dropped – center, font, strike
  • 弃用元素-中心,字体,打击

#3


11  

You'll want to check here for the complete diff. But there are many new elements and element attributes. Some elements were removed and others have different semantic value than before. There are also APIs defined, such as the use of canvas, to help build the next generation of web apps and make sure implementations are standardized.

您将在这里检查完整的diff,但是有许多新的元素和元素属性。一些元素被删除,另一些元素具有不同的语义价值。还定义了一些api,比如使用canvas,来帮助构建下一代web应用程序,并确保实现标准化。

#4


10  

HTML5 introduces a number of APIs that help in creating Web applications. These can be used together with the new elements introduced for applications:

HTML5引入了许多帮助创建Web应用程序的api。这些可与为应用而引入的新元素一起使用:

  • An API for playing of video and audio which can be used with the new video and audio elements.
  • 一个用于播放视频和音频的API,可以与新的视频和音频元素一起使用。
  • An API that enables offline Web applications.
  • 支持离线Web应用程序的API。
  • An API that allows a Web application to register itself for certain protocols or media types.
  • 允许Web应用程序为某些协议或媒体类型注册自身的API。
  • An editing API in combination with a new global contenteditable attribute.
  • 与新的全局contenteditable属性相结合的编辑API。
  • A drag & drop API in combination with a draggable attribute.
  • 拖放API与可拖放属性结合使用。
  • An API that exposes the history and allows pages to add to it to prevent breaking the back button.
  • 公开历史并允许页面添加到历史记录的API,以防止破坏后退按钮。

#5


3  

You might be interested in this list of HTML5 elements and attributes.

您可能对HTML5元素和属性的列表感兴趣。

Also, please note that it's "HTML 4", not "HTML4". Indeed, for HTML 5, both variants are used, but there is an important difference in meaning. HTML 5 refers to the name of the W3C specification, whereas "HTML5" is the document type of those HTML files with a text/html MIME type that follow this spec. The same goes for XHTML 5 vs. XHTML5.

另外,请注意它是“HTML4”,而不是“HTML4”。实际上,对于HTML 5,这两种变体都被使用,但是在意义上有一个重要的区别。HTML5是W3C规范的名称,而“HTML5”是这些HTML文件的文档类型,文本/ HTML MIME类型遵循此规范。

#6


2  

Now W3c provides an official difference on their site:

现在W3c在他们的网站上提供了一个官方的区别:

http://www.w3.org/TR/html5-diff/

http://www.w3.org/TR/html5-diff/

#7


0  

HTML 5 invites you give add a lot of semantic value to your code. What's more, there are natives solution to embed multimedia content.

HTML 5邀请你给你的代码添加很多语义价值。此外,还有本地解决方案来嵌入多媒体内容。

The rest is important, but it's more technical sugar that will save you from doing the same stuff with a client programming language.

其余的内容很重要,但更专业的内容将使您避免使用客户端编程语言做同样的事情。

#8


0  

In short it is much simple compared to html, the long doctype is removed and also center and font tag is removed. I also answered this difference in my blog : http://ravisinghblog.in/key-difference-between-html-and-html-5/

简而言之,与html相比,它简单多了,删除了长文档类型,删除了中心和字体标记。我在博客中也回答了这个问题:http://ravisinghblog.in/key-difference between en-html-and-html-5/

#1


185  

HTML5 has several goals which differentiate it from HTML4.

HTML5有几个不同于HTML4的目标。

Consistency in Handling Malformed Documents

The primary one is consistent, defined error handling. As you know, HTML purposely supports 'tag soup', or the ability to write malformed code and have it corrected into a valid document. The problem is that the rules for doing this aren't written down anywhere. When a new browser vendor wants to enter the market, they just have to test malformed documents in various browsers (especially IE) and reverse-engineer their error handling. If they don't, then many pages won't display correctly (estimates place roughly 90% of pages on the net as being at least somewhat malformed).

主要的是一致的、定义好的错误处理。正如您所知道的,HTML有意地支持“标签汤”,即编写畸形代码并将其修改为有效文档的能力。问题是这样做的规则没有写下来。当一个新的浏览器供应商想要进入市场时,他们只需要在不同的浏览器(尤其是IE)中测试格式错误的文档并反向设计他们的错误处理。如果他们不这样做,那么许多页面将无法正确显示(估计大约90%的页面在网络上被认为至少有一些畸形)。

So, HTML5 is attempting to discover and codify this error handling, so that browser developers can all standardize and greatly reduce the time and money required to display things consistently. As well, long in the future after HTML has died as a document format, historians may still want to read our documents, and having a completely defined parsing algorithm will greatly aid this.

因此,HTML5正试图发现并编写这种错误处理,以便浏览器开发人员都能标准化并大大减少持续显示内容所需的时间和金钱。同样,在HTML作为一种文档格式而死后,历史学家可能仍然希望阅读我们的文档,并且拥有一个完全定义的解析算法将极大地帮助这一点。

Better Web Application Features

The secondary goal of HTML5 is to develop the ability of the browser to be an application platform, via HTML, CSS, and Javascript. Many elements have been added directly to the language that are currently (in HTML4) Flash or JS-based hacks, such as <canvas>, <video>, and <audio>. Useful things such as Local Storage (a js-accessible browser-built-in key-value database, for storing information beyond what cookies can hold), new input types such as date for which the browser can expose easy user interface (so that we don't have to use our js-based calendar date-pickers), and browser-supported form validation will make developing web applications much simpler for the developers, and make them much faster for the users (since many things will be supported natively, rather than hacked in via javascript).

HTML5的第二个目标是通过HTML、CSS和Javascript开发浏览器作为应用平台的能力。许多元素被直接添加到当前(在HTML4中)Flash或基于jms的hack语言中,比如

Improved Element Semantics

There are many other smaller efforts taking place in HTML5, such as better-defined semantic roles for existing elements (<strong> and <em> now actually mean something different, and even <b> and <i> have vague semantics that should work well when parsing legacy documents) and adding new elements with useful semantics - <article>, <section>, <header>, <aside>, and <nav> should replace the majority of <div>s used on a web page, making your pages a bit more semantic, but more importantly, easier to read. No more painful scanning to see just what that random </div> is closing - instead you'll have an obvious </header>, or </article>, making the structure of your document much more intuitive.

还有许多其他较小的努力发生在HTML5,增速甚至语义角色等现有元素( <强> 和< em >实际上意味着不同的东西,甚至是< b >和 <我> 模糊语义解析时要做好遗留文档)和添加新元素提供有用的语义—— <文> , <节> 、 <标题> 、< >,和 <导航> 应该取代大部分的< div > s上使用一个web页面,使页面更加语义,但更重要的是,更容易阅读。没有比随机的关闭更痛苦的扫描了——相反,您将有一个明显的,或,使您的文档结构更直观。

#2


41  

From Wikipedia:

从*:

  • New parsing rules oriented towards flexible parsing and compatibility
  • 面向灵活解析和兼容性的新解析规则
  • New elements – section, video, progress, nav, meter, time, aside, canvas
  • 新元素-切片,视频,进度,导航,米,时间,旁白,画布
  • New input attributes – dates and times, email, url
  • 新的输入属性-日期和时间,电子邮件,url
  • New attributes – ping, charset, async
  • 新属性- ping, charset, async
  • Global attributes (that can be applied for every element) – id, tabindex, repeat
  • 全局属性(可以应用于每个元素)- id, tabindex, repeat
  • Deprecated elements dropped – center, font, strike
  • 弃用元素-中心,字体,打击

#3


11  

You'll want to check here for the complete diff. But there are many new elements and element attributes. Some elements were removed and others have different semantic value than before. There are also APIs defined, such as the use of canvas, to help build the next generation of web apps and make sure implementations are standardized.

您将在这里检查完整的diff,但是有许多新的元素和元素属性。一些元素被删除,另一些元素具有不同的语义价值。还定义了一些api,比如使用canvas,来帮助构建下一代web应用程序,并确保实现标准化。

#4


10  

HTML5 introduces a number of APIs that help in creating Web applications. These can be used together with the new elements introduced for applications:

HTML5引入了许多帮助创建Web应用程序的api。这些可与为应用而引入的新元素一起使用:

  • An API for playing of video and audio which can be used with the new video and audio elements.
  • 一个用于播放视频和音频的API,可以与新的视频和音频元素一起使用。
  • An API that enables offline Web applications.
  • 支持离线Web应用程序的API。
  • An API that allows a Web application to register itself for certain protocols or media types.
  • 允许Web应用程序为某些协议或媒体类型注册自身的API。
  • An editing API in combination with a new global contenteditable attribute.
  • 与新的全局contenteditable属性相结合的编辑API。
  • A drag & drop API in combination with a draggable attribute.
  • 拖放API与可拖放属性结合使用。
  • An API that exposes the history and allows pages to add to it to prevent breaking the back button.
  • 公开历史并允许页面添加到历史记录的API,以防止破坏后退按钮。

#5


3  

You might be interested in this list of HTML5 elements and attributes.

您可能对HTML5元素和属性的列表感兴趣。

Also, please note that it's "HTML 4", not "HTML4". Indeed, for HTML 5, both variants are used, but there is an important difference in meaning. HTML 5 refers to the name of the W3C specification, whereas "HTML5" is the document type of those HTML files with a text/html MIME type that follow this spec. The same goes for XHTML 5 vs. XHTML5.

另外,请注意它是“HTML4”,而不是“HTML4”。实际上,对于HTML 5,这两种变体都被使用,但是在意义上有一个重要的区别。HTML5是W3C规范的名称,而“HTML5”是这些HTML文件的文档类型,文本/ HTML MIME类型遵循此规范。

#6


2  

Now W3c provides an official difference on their site:

现在W3c在他们的网站上提供了一个官方的区别:

http://www.w3.org/TR/html5-diff/

http://www.w3.org/TR/html5-diff/

#7


0  

HTML 5 invites you give add a lot of semantic value to your code. What's more, there are natives solution to embed multimedia content.

HTML 5邀请你给你的代码添加很多语义价值。此外,还有本地解决方案来嵌入多媒体内容。

The rest is important, but it's more technical sugar that will save you from doing the same stuff with a client programming language.

其余的内容很重要,但更专业的内容将使您避免使用客户端编程语言做同样的事情。

#8


0  

In short it is much simple compared to html, the long doctype is removed and also center and font tag is removed. I also answered this difference in my blog : http://ravisinghblog.in/key-difference-between-html-and-html-5/

简而言之,与html相比,它简单多了,删除了长文档类型,删除了中心和字体标记。我在博客中也回答了这个问题:http://ravisinghblog.in/key-difference between en-html-and-html-5/