HTML6 初探 — 你没看错,是6不是5

开发 前端
HTML5 是 HTML 语言最受欢迎的版本之一,它支持音频和视频、离线存储、移动端、和标签属性等等。还提供一些标签来帮助开发者更好地组织页面内容。然而 HTML5 规范仍然没有最后定稿,并且它并不是一个真正意义上的语义标记语言。

HTML5 概述

HTML5 是 HTML 语言***的版本之一,它支持音频和视频、离线存储、移动端、和标签属性等等。还提供了<article>, <section>, <header>这样的标签来帮助开发者更好地组织页面内容。然而 HTML5 规范仍然没有***定稿,并且它并不是一个真正意义上的语义标记语言。

HTML6 展望

\

你有没有曾经希望能在 HTML 中使用自定义标签?比如:使用<logo>来显示你的网站logo,还有使用<toolbar>来显示工具栏等等。我们经常使用<div id=”container”>和<div id=”wrapper”>来组织页面,在 HTML6 里我们希望可以直接使用象<container>和<wrapper>这样的自定义标签。

和 XML 一样,HTML6 应该支持 namespace(命名空间),如:xmlns:xhtml=”http://www.w3.org/1999/xhtml”

HTML6 代码样例:

  1. <!DOCTYPE&nbsp;html> 
  2.  
  3. &nbsp;<html:html> 
  4.  
  5. &nbsp;<html:head> 
  6.  
  7. &nbsp;<html:title>A&nbsp;Look&nbsp;Into&nbsp;HTML6</html:title> 
  8.  
  9. &nbsp;<html:meta&nbsp;type="title"&nbsp;value="Page&nbsp;Title"> 
  10.  
  11. &nbsp;<html:meta&nbsp;type="description"&nbsp;value="HTML&nbsp;example&nbsp;with&nbsp;namespaces"> 
  12.  
  13. &nbsp;<html:link&nbsp;src="css/mainfile.css"&nbsp;title="Styles"&nbsp;type="text/css"> 
  14.  
  15. &nbsp;<html:link&nbsp;src="js/mainfile.js"&nbsp;title="Script"&nbsp;type="text/javascript"> 
  16.  
  17. &nbsp;</html:head> 
  18.  
  19. &nbsp;<html:body> 
  20.  
  21. &nbsp;<header> 
  22.  
  23. &nbsp;<logo> 
  24.  
  25. &nbsp;<html:media&nbsp;type="image"&nbsp;src="images/xyz.png"> 
  26.  
  27. &nbsp;</logo> 
  28.  
  29. &nbsp;<nav> 
  30.  
  31. &nbsp;<html:a&nbsp;href="/img1">a1</a> 
  32.  
  33. &nbsp;<html:a&nbsp;href="/img2">a2</a> 
  34.  
  35. &nbsp;</nav> 
  36.  
  37. &nbsp;</header> 
  38.  
  39. &nbsp;<content> 
  40.  
  41. &nbsp;<article> 
  42.  
  43. &nbsp;<h1>Heading&nbsp;of&nbsp;main&nbsp;article</h1> 
  44.  
  45. &nbsp;<h2>Sub-heading&nbsp;of&nbsp;main&nbsp;article</h2> 
  46.  
  47. &nbsp;<p>[...]</p> 
  48.  
  49. &nbsp;<p>[...]</p> 
  50.  
  51. &nbsp;</article> 
  52.  
  53. &nbsp;<article> 
  54.  
  55. &nbsp;<h1>The&nbsp;concept&nbsp;of&nbsp;HTML6</h1> 
  56.  
  57. &nbsp;<h2>Understanding&nbsp;the&nbsp;basics</h2> 
  58.  
  59. &nbsp;<p>[...]</p> 
  60.  
  61. &nbsp;</article> 
  62.  
  63. &nbsp;</content> 
  64.  
  65. &nbsp;<footer> 
  66.  
  67. &nbsp;<copyright>This&nbsp;site&nbsp;is&nbsp;©&nbsp;to&nbsp;Anonymous&nbsp;2014</copyright> 
  68.  
  69. &nbsp;</footer> 
  70.  
  71. &nbsp;</html:body> 
  72.  
  73. &nbsp;</html:html> 

在上面的代码中,你也许注意到了一些奇怪的<html:x>标签,它们是 W3C 和 HTML6 规范中在命名空间里定义的标签。例如:<html:title>负责设定你浏览器的标题栏文字,<html:media>负责显示图片等等。用户可以自己定义标签以便 JavaScript 和 CSS 识别和处理,这样页面代码会更易读,语义更清晰。

HTML6 APIs

HTML6 的标签前带有命名空间,如:<html:html>, <html:head>等等。

1. <html:html>

  1. <!DOCTYPE&nbsp;html> 
  2.  
  3. &nbsp;<html:html>//&nbsp;this&nbsp;is&nbsp;equivalent&nbsp;to&nbsp;<html>&nbsp;tag&nbsp;written&nbsp;in&nbsp;previous&nbsp;HTML&nbsp;versions 
  4.  
  5. &nbsp;<!--&nbsp;sample&nbsp;of&nbsp;HTML&nbsp;document&nbsp;--> 
  6.  
  7. &nbsp;</html:html> 

2. <html:head> 和 <head> 标签一样。

  1. <!DOCTYPE&nbsp;html> 
  2.  
  3. &nbsp;<html:html> 
  4.  
  5. &nbsp;<html:head> 
  6.  
  7. &nbsp;<!--&nbsp;Main&nbsp;content&nbsp;would&nbsp;come&nbsp;here,&nbsp;like&nbsp;the&nbsp;<html:title>&nbsp;tag&nbsp;--> 
  8.  
  9. &nbsp;</html:head> 
  10.  
  11. &nbsp;</html:html> 

3. <html:title> 和 <title> 标签类似。

  1. <!DOCTYPE&nbsp;html> 
  2.  
  3. &nbsp;<html:html> 
  4.  
  5. &nbsp;<html:head> 
  6.  
  7. &nbsp;<html:title>A&nbsp;Look&nbsp;Into&nbsp;HTML6</html:title> 
  8.  
  9. &nbsp;</html:head> 
  10.  
  11. &nbsp;</html:html> 

4. <html:meta> 和 <meta> 标签类似,不同之处在于,在 HTML5 中你只能使用标准的元数据类型,如:”keywords”, “description”, “author”等,而在 HTML6 中你可以使用任何元数据类型。

  1. <!DOCTYPE&nbsp;html> 
  2.  
  3. &nbsp;<html:html> 
  4.  
  5. &nbsp;<html:head> 
  6.  
  7. &nbsp;<html:title>A&nbsp;Look&nbsp;Into&nbsp;HTML6</html:title> 
  8.  
  9. &nbsp;<html:meta&nbsp;type="description"&nbsp;value="HTML&nbsp;example&nbsp;with&nbsp;namespaces"> 
  10.  
  11. &nbsp;</html:head> 
  12.  
  13. &nbsp;</html:html> 

5. <html:link> 和 HTML6 之前版本的 <link> 标签类似。

  1. <!DOCTYPE&nbsp;html> 
  2.  
  3. &nbsp;<html:html> 
  4.  
  5. &nbsp;<html:head> 
  6.  
  7. &nbsp;<html:title>A&nbsp;Look&nbsp;Into&nbsp;HTML6</html:title> 
  8.  
  9. &nbsp;<html:link&nbsp;src="js/mainfile.js"&nbsp;title="Script"&nbsp;type="text/javascript"> 
  10.  
  11. &nbsp;</html:head> 
  12.  
  13. &nbsp;</html:html> 

6. <html:body> 和 <body> 标签一样。

  1. <!DOCTYPE&nbsp;html> 
  2.  
  3. &nbsp;<html:html> 
  4.  
  5. &nbsp;<html:head> 
  6.  
  7. &nbsp;<html:title>A&nbsp;Look&nbsp;Into&nbsp;HTML6</html:title> 
  8.  
  9. &nbsp;</html:head> 
  10.  
  11. &nbsp;<html:body> 
  12.  
  13. &nbsp;<!--&nbsp;This&nbsp;is&nbsp;where&nbsp;your&nbsp;website&nbsp;content&nbsp;is&nbsp;placed&nbsp;--> 
  14.  
  15. &nbsp;</html:body> 
  16.  
  17. &nbsp;</html:html> 

7. <html:a> 和 <a> 标签类似,区别是 <html:a> 只有 “href” 一个属性。

  1. <!DOCTYPE&nbsp;html> 
  2.  
  3. &nbsp;<html:html> 
  4.  
  5. &nbsp;<html:head> 
  6.  
  7. &nbsp;<html:title>A&nbsp;Look&nbsp;Into&nbsp;HTML6</html:title> 
  8.  
  9. &nbsp;</html:head> 
  10.  
  11. &nbsp;<html:body> 
  12.  
  13. &nbsp;<html:a&nbsp;href="http://siteurl">Go&nbsp;to&nbsp;siteurl.com!</html:a> 
  14.  
  15. &nbsp;</html:body> 
  16.  
  17. &nbsp;</html:html> 

8. <html:button> 和 <button> 及 <input type=”button”> 一样。

  1. <!DOCTYPE&nbsp;html> 
  2.  
  3. &nbsp;<html:html> 
  4.  
  5. &nbsp;<html:head> 
  6.  
  7. &nbsp;<html:title>A&nbsp;Look&nbsp;Into&nbsp;HTML6</html:title> 
  8.  
  9. &nbsp;</html:head> 
  10.  
  11. &nbsp;<html:body> 
  12.  
  13. &nbsp;<html:button>Click&nbsp;Here</html:button> 
  14.  
  15. &nbsp;</html:body> 
  16.  
  17. &nbsp;</html:html> 

9. <html:media> 涵盖 <img>, <video>, <embed> 等标签的所有功能。<html:media> 的好处是你不用根据不同的媒体文件类型使用不同的标签,媒体的类型由浏览器从文件内容(类型属性,扩展名,和MIME type)中来判断。

  1. <!DOCTYPE&nbsp;html> 
  2.  
  3. &nbsp;<html:html> 
  4.  
  5. &nbsp;<html:head> 
  6.  
  7. &nbsp;<html:title>A&nbsp;Look&nbsp;Into&nbsp;HTML6</html:title> 
  8.  
  9. &nbsp;</html:head> 
  10.  
  11. &nbsp;<html:body> 
  12.  
  13. &nbsp;<!--&nbsp;Image&nbsp;would&nbsp;come&nbsp;here&nbsp;--> 
  14.  
  15. &nbsp;<html:media&nbsp;src="img1/logo.jpg"&nbsp;type="image"> 
  16.  
  17. &nbsp;<!--&nbsp;Video&nbsp;doesn't&nbsp;need&nbsp;a&nbsp;type&nbsp;--> 
  18.  
  19. &nbsp;<html:media&nbsp;src="videos/slide.mov"> 
  20.  
  21. &nbsp;</html:body> 
  22.  
  23. &nbsp;</html:html> 

标签类型(Tag types)概述

和 HTML5 一样, HTML6 也有两种标签类型:单标签(single tag) 和双标签(double tag)

  1. <html:meta&nbsp;type="author"&nbsp;content="single&nbsp;tag"> 
  2.  
  3. &nbsp;<html:meta&nbsp;type="author"&nbsp;content="double&nbsp;tag"&nbsp;/> 

单标签不需要结束符’/’

结语

HTML6 规范还未发布,本文原作者Oscar Godson 只是为我们提供了一个对 HTML6 规范的展望,或者说他希望 HTML6 能够支持的一些新特性。

原文链接:A Look Into HTML6 – What Is It, and What Does it Have to Offer?

原文地址:http://www.udpwork.com/item/13608.html

责任编辑:张伟 来源: 酷 壳 – CoolShell.cn
相关推荐

2015-03-30 09:26:24

JavaScriptHTML6

2021-05-26 10:19:01

jreJava应用程序

2014-06-19 14:49:37

iCloud认证令牌密码

2017-09-18 11:51:50

2015-03-30 14:53:12

HTML6JavaScript一片哗然

2014-11-06 14:48:42

GoogleFacebook

2009-09-08 13:47:11

SproutCoreHTML 5应用框架

2010-08-10 09:08:29

WebSocketsHTML 5

2010-03-03 08:36:49

HTML 5 Web

2019-04-09 10:45:18

IPv6运营商协议

2023-01-04 11:39:45

2011-09-27 17:37:22

2017-10-20 12:18:02

HTML5代码header

2020-08-04 17:12:47

5G6G数据传输

2018-11-27 14:57:00

IPv6IPv4网络

2012-02-29 15:46:48

HTML 5

2012-11-15 09:59:35

HTML5WebHTML5特效

2015-10-26 14:30:36

数据分析炒菜搬运工

2019-10-18 09:24:29

WiFi5GWiFi6

2020-04-26 12:31:20

马斯克卫星5G
点赞
收藏

51CTO技术栈公众号