html6 展望 你有没有曾经希望能在 html 中使用自定义标签?比如:使用8362cb02e0cfc24a3b7574ffd3d04706来显示你的网站logo,还有使用355ac7d41ec9425e0b523a42df5495a6来显示工具栏等等。我们经常使用18ff79a4a4efe2fdc4e89732e7a7c8d2和ba0b255d62538cb44564d689b6be2981来组织页面,在 html6 里我们希望可以直接使用象53a242729f514007e759e47ee2429b4a和618d5c346957085eade432fbb0384458这样的自定义标签。
html6 代码样例:<!doctype html> <html:html> <html:head> <html:title>a look into html6</html:title> <html:meta type="title" value="page title"> <html:meta type="description" value="html example with namespaces"> <html:link src="css/mainfile.css" title="styles" type="text/css"> <html:link src="js/mainfile.js" title="script" type="text/javascript"> </html:head> <html:body> <header> <logo> <html:media type="image" src="images/xyz.png"> </logo> <nav> <html:a href="/img1">a1</a> <html:a href="/img2">a2</a> </nav> </header> <content> <article> <h1>heading of main article</h1> <h2>sub-heading of main article</h2> <p>[...]</p> <p>[...]</p> </article> <article> <h1>the concept of html6</h1> <h2>understanding the basics</h2> <p>[...]</p> </article> </content> <footer> <copyright>this site is © to anonymous 2014</copyright> </footer> </html:body> </html:html>
在上面的代码中,你也许注意到了一些奇怪的<html:x>标签,它们是 w3c 和 html6 规范中在命名空间里定义的标签。例如:<html:title>负责设定你浏览器的标题栏文字,<html:media>负责显示图片等等。用户可以自己定义标签以便 javascript 和 css 识别和处理,这样页面代码会更易读,语义更清晰。
html6 apis html6 的标签前带有命名空间,如:<html:html>, <html:head>等等。
1. <html:html>
<!doctype html> <html:html>// this is equivalent to <html> tag written in previous html versions <!-- sample of html document --> </html:html>
2. <html:head> 和 <head> 标签一样。
<!doctype html> <html:html> <html:head> <!-- main content would come here, like the <html:title> tag --> </html:head> </html:html>
3. <html:title> 和 <title> 标签类似。
<!doctype html> <html:html> <html:head> <html:title>a look into html6</html:title> </html:head> </html:html>
4. <html:meta> 和 <meta> 标签类似,不同之处在于,在 html5 中你只能使用标准的元数据类型,如:”keywords”, “description”, “author”等,而在 html6 中你可以使用任何元数据类型。
<!doctype html> <html:html> <html:head> <html:title>a look into html6</html:title> <html:meta type="description" value="html example with namespaces"> </html:head> </html:html>
5. <html:link> 和 html6 之前版本的 <link> 标签类似。
<!doctype html> <html:html> <html:head> <html:title>a look into html6</html:title> <html:link src="js/mainfile.js" title="script" type="text/javascript"> </html:head> </html:html>
6. <html:body> 和 <body> 标签一样。
<!doctype html> <html:html> <html:head> <html:title>a look into html6</html:title> </html:head> <html:body> <!-- this is where your website content is placed --> </html:body> </html:html>
7. <html:a> 和 <a> 标签类似,区别是 <html:a> 只有 “href” 一个属性。
<!doctype html> <html:html> <html:head> <html:title>a look into html6</html:title> </html:head> <html:body> <html:a href="http://siteurl">go to siteurl.com!</html:a> </html:body> </html:html>
8. <html:button> 和 <button> 及 <input type=”button”> 一样。
<!doctype html> <html:html> <html:head> <html:title>a look into html6</html:title> </html:head> <html:body> <html:button>click here</html:button> </html:body> </html:html>
9. <html:media> 涵盖 <img>, <video>, <embed> 等标签的所有功能。<html:media> 的好处是你不用根据不同的媒体文件类型使用不同的标签,媒体的类型由浏览器从文件内容(类型属性,扩展名,和mime type)中来判断。
<!doctype html> <html:html> <html:head> <html:title>a look into html6</html:title> </html:head> <html:body> <!-- image would come here --> <html:media src="img1/logo.jpg" type="image"> <!-- video doesn't need a type --> <html:media src="videos/slide.mov"> </html:body> </html:html>
标签类型(tag types)概述和 html5 一样, html6 也有两种标签类型:单标签(single tag) 和双标签(double tag)
<html:meta type="author" content="single tag"> <html:meta type="author" content="double tag" />
单标签不需要结束符’/’
结语html6 规范还未发布,本文原作者oscar godson 只是为我们提供了一个对 html6 规范的展望,或者说他希望 html6 能够支持的一些新特性。
以上就是html6的展望与代码的详细内容。
