HTML5新特性
簡潔的DOCTYPE:
HTML5 只有一個簡單的文檔類型:<!DOCTYPE html>
,表示瀏覽器會按照標準模式解析。
簡單易記的編碼類型
你現在可以在meta 標簽中使用”charset”:<meta charset=”utf-8″ />
腳本和鏈接無需type
<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新特性之語義化標簽,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對武林網網站的支持!
新聞熱點
疑難解答