HTML5 只有一個簡單的文件類型:<!DOCTYPE html> ,表示瀏覽器會依照標準模式解析。
你現在可以在meta 標籤中使用charset: <meta charset=utf-8″ />
<link rel=stylesheet href=path/to/stylesheet.css /><script src=path/to/script.js></script>更語意化的新增標籤
例如:<article>、<section>、<aside>、<hgroup>、 <header>,<footer>、<nav>、<time>、<mark>、<figure> 和<figcaption>等
視訊和音訊<video width=640 height=320 preload=auto poster=0.jpg controls> <source src=movie.ogg type=video/ogg /> <source src=movie.mp4 type=video/mp4 /> Your browser does not support the video tag.</video>表單增強
新的input類型:color, email, date, month, week, time, datetime, datetime-local, number,range,search, tel, 和url
新屬性:required, autofocus, pattern, list, autocomplete 和placeholder
新元素:<keygen>, <datalist>, <output>, <meter> 和<progress>
canvas標籤繪製2D圖形。
var canvas = document.getElementById('canvas');var context = canvas.getContext('2d');context.beginPath();context.moveTo(100,100);context.lineTo(300,300);context.lineTo(100,500) ;context.lineWidth = 5;context.strokeStyle = red;context.stroke();地理位置獲取HTML語意化1.什麼是HTML語意化?透過標籤判斷內容語義,例如根據h1標籤判斷出內容是標題,根據<p>判斷內容是段落、<input>標籤是輸入框等。
2.為什麼要語意化?1).去掉或樣式遺失的時候能讓頁面呈現清楚的結構
2).方便其他設備解析(如螢幕閱讀器、盲人閱讀器、行動裝置)以意義的方式來渲染網頁
3).有利於SEO
4).便於團隊開發與維護,遵循W3C標準,可減少差異化
3.如何確定你的標籤是否語意良好?去掉樣式,看看網頁結構是否組織良好有序,是否仍有很好的可讀性。
4.常見的語意化標籤模組表單
<form action= method=> <fieldset style=border: none> <legend style=display: none>登入表單</legend> <p><label for=name>帳號:</label><input type=text id =name></p> <p><label for=pw>密碼:</label><input type=password id=pw></p> <input type=submit name=登入class=subBtn> </fieldset></form>
表單域要用fieldset標籤包起來,並用legend標籤說明表單的用途;每個input標籤對應的說明文字都需要使用label標籤,並且透過為input設定id屬性,在lable標籤中設定for=someld來讓說明文字和相對應的input關聯起來。
5.語意化標籤應注意的一些問題盡可能少的使用無語義的標籤div和span;
在語意不明顯時,既可以使用div或p時,盡量用p, 因為p在預設情況下有上下間距,對相容特殊終端有利;
不要使用純樣式標籤,如:b、font、u等,改用css設定。
需要強調的文本,可以包含在strong或em標籤中,strong預設樣式是加粗(不要用b),em是斜體(不用i)
總結以上所述是小編給大家介紹的HTML5新特性之語意化標籤,希望對大家有幫助,如果大家有任何疑問請給我留言,小編會及時回覆大家的。在此也非常感謝大家對VeVb武林網站的支持!