百度JavaScript/HTML/CSS編碼規範:javascript
JavaScript: http://gitlab.baidu.com/fe/spec/blob/master/javascript.mdcss
HTML: http://gitlab.baidu.com/fe/spec/blob/master/html.mdhtml
CSS: http://gitlab.baidu.com/fe/spec/blob/master/css.md java
· 標準模板git
<!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width,user-scalable=no"> <title>頁面標題</title></head> <link rel="shortcut icon" href="path/to/favicon.ico"> <link rel="stylesheet" href="page.css"> ...... </head> <body> ...... <script src="init-behavior.js"></script> </body> </html>
· 塊級元素 通常用來搭建網站架構、佈局、承載內容……像這些大致力活都屬於塊級元素的,它包括如下這些標籤:瀏覽器
address、blockquote、center、dir、div、dl、dt、dd、fieldset、form、h1~h六、hr、isindex、menu、noframes、noscript、ol、p、pre、table、ul架構
· 內嵌元素 通常用在網站內容之中的某些細節或部位,用以「強調、區分樣式、上標、下標、錨點」等等,下面這些標籤都屬於內嵌元素:ide
a、abbr、acronym、b、bdo、big、br、cite、code、dfn、em、font、i、img、input、kbd、label、q、s、samp、select、small、span、strike、strong、sub、sup、textarea、tt、u、vargitlab
· 通常塊級元素能包含塊級/內嵌元素,內嵌元素不能包含塊級元素,內嵌元素能包含內嵌元素。佈局
特殊一:有幾個特殊的塊級元素只能包含內嵌元素,不能再包含塊級元素,這幾個特殊的標籤是:
h一、h二、h三、h四、h五、h六、p、dt
特殊二:li 內能夠包含 div 標籤【li 和 div 標籤都是裝載內容的容器,地位平等,沒有級別之分(例如:h一、h2 這樣森嚴的等級制度^_^),要知道,li 標籤連它的父級 ul 或者是 ol 均可以容納的】
· 下面是常見標籤語義
p - 段落
h1,h2,h3,h4,h5,h6 - 層級標題
strong,em - 強調
ins - 插入
del - 刪除
abbr - 縮寫
code - 代碼標識
cite - 引述來源做品的標題
q - 引用
blockquote - 一段或長篇引用
ul - 無序列表
ol - 有序列表
dl,dt,dd - 定義列表
· favicon.ico通常用於做爲縮略的網站標誌,它顯示位於瀏覽器的地址欄或者在標籤上,用於顯示網站的logo。
· 多媒體處理
<audio controls> <source src="audio.mp3" type="audio/mpeg"> <source src="audio.ogg" type="audio/ogg"> <object width="100" height="50" data="audio.mp3"> <embed width="100" height="50" src="audio.swf"> </object> </audio><video width="100" height="50" controls> <source src="video.mp4" type="video/mp4"> <source src="video.ogg" type="video/ogg"> <object width="100" height="50" data="video.mp4"> <embed width="100" height="50" src="video.swf"> </object> </video>
object
標籤內部提供指示瀏覽器不支持該標籤的說明。<object width="100" height="50" data="something.swf">DO NOT SUPPORT THIS TAG</object>