百度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>