HTML5 是 HTML 語言最受歡迎的版本之一,它支持音頻和視頻、離線存儲(chǔ)、移動(dòng)端、和標(biāo)簽屬性等等。還提供了<article>, <section>, <header>這樣的標(biāo)簽來幫助開發(fā)者更好地組織頁面內(nèi)容。然而 HTML5 規(guī)范仍然沒有最后定稿,并且它并不是一個(gè)真正意義上的語義標(biāo)記語言。

你有沒有曾經(jīng)希望能在 HTML 中使用自定義標(biāo)簽?比如:使用<logo>來顯示你的網(wǎng)站logo,還有使用<toolbar>來顯示工具欄等等。我們經(jīng)常使用<div id=”container”>和<div id=”wrapper”>來組織頁面,在 HTML6 里我們希望可以直接使用象<container>和<wrapper>這樣的自定義標(biāo)簽。
和 xml 一樣,HTML6 應(yīng)該支持 namespace(命名空間),如:xmlns:xhtml=”http://www.w3.org/1999/xhtml”
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="descrCSS/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>標(biāo)簽,它們是 W3C 和 HTML6 規(guī)范中在命名空間里定義的標(biāo)簽。例如:<html:title>負(fù)責(zé)設(shè)定你瀏覽器的標(biāo)題欄文字,<html:media>負(fù)責(zé)顯示圖片等等。用戶可以自己定義標(biāo)簽以便 Javascript 和 CSS 識(shí)別和處理,這樣頁面代碼會(huì)更易讀,語義更清晰。
HTML6 的標(biāo)簽前帶有命名空間,如:<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> 標(biāo)簽一樣。
<!DOCTYPE html> <html:html> <html:head> <!-- Main content would come here, like the <html:title> tag --> </html:head> </html:html>
3. <html:title> 和 <title> 標(biāo)簽類似。
<!DOCTYPE html> <html:html> <html:head> <html:title>A Look Into HTML6</html:title> </html:head> </html:html>
4. <html:meta> 和 <meta> 標(biāo)簽類似,不同之處在于,在 HTML5 中你只能使用標(biāo)準(zhǔn)的元數(shù)據(jù)類型,如:”keyWords”, “description”, “author”等,而在 HTML6 中你可以使用任何元數(shù)據(jù)類型。
<!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> 標(biāo)簽類似。
<!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> 標(biāo)簽一樣。
<!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> 標(biāo)簽類似,區(qū)別是 <html:a> 只有 “href” 一個(gè)屬性。
<!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> 等標(biāo)簽的所有功能。<html:media> 的好處是你不用根據(jù)不同的媒體文件類型使用不同的標(biāo)簽,媒體的類型由瀏覽器從文件內(nèi)容(類型屬性,擴(kuò)展名,和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>
和 HTML5 一樣, HTML6 也有兩種標(biāo)簽類型:?jiǎn)螛?biāo)簽(single tag) 和雙標(biāo)簽(double tag)
<html:meta type="author" content="single tag"> <html:meta type="author" content="double tag" />
單標(biāo)簽不需要結(jié)束符’/’
HTML6 規(guī)范還未發(fā)布,本文原作者Oscar Godson 只是為我們提供了一個(gè)對(duì) HTML6 規(guī)范的展望,或者說他希望 HTML6 能夠支持的一些新特性。
新聞熱點(diǎn)
疑難解答
圖片精選
網(wǎng)友關(guān)注