XHTML&CSS标准化文档
20100329更新
目 录
第一章 XHTML标准... 2
一、 XHTML文档结构... 2
1、 定义文档类型:... 2
2、 声明命名空间:... 2
3、 编码类型:... 2
二、 XHTML书写规范... 3
1、 语法规范:... 3
2、 注释规范:... 3
第二章 CSS标准化及CSS框架... 4
一、 CSS文档统筹与编码规范... 4
1、 CSS文档统筹:... 4
2、 CSS书写的规范:... 5
3、 属性的组织:... 6
4、 A属性排列顺序:... 6
5、 CSS命名规则:... 7
6、 CSS命名方法:... 7
二、 Reset CSS. 10
三、 清除浮动方法... 11
第三章 通用规范... 12
一、 文档结构和命名规范... 12
1、 Style文件命名规范:... 13
2、 Images规范:... 13
3、 Javascript规范:... 14
第四章 项目制作完成... 15
一、 代码的优化(制作部分)... 15
二、 夸浏览器兼容性... 16
1、 测试代码在各主流浏览器兼容性:... 16
三、 项目的上传... 16
第五章 页面制作中的SEO规范... 17
一、 页面制作中的SEO规范... 17
附录:设计规范... 18
一、 页面设计尺寸... 18
二、 字体规定... 18
三、 字号规定... 18
四、 行高规定... 18
五、 图片尺寸规范... 19
六、 文本颜色... 20
七、 切图规则... 20
第一章 XHTML标准
过渡型DTD(XHTML 1.0 Transitional)是比较理想的选择。因为这种DTD允许使用描述性的元素和属性,也比较容易通过W3C的代码校验。
定义文档类型:过渡型(Transitional) |
xmlns是XHTML NameSpace的缩写,中文翻译为命名空间。命名空间是收集元素类型和属性名字的一个详细DTD,如果不指明各自的命名空间,机会出现语义混淆现象。
声明命名空间 |
编码类型:GB2312
语法规范 |
1、 XHTML对大小写敏感,所有的元素和属性都必须小写。 2、 所有的属性必须用引号””括起来。 3、 XHTML要求有严谨的结构,因此所有的标签都必须合理嵌套 4、 所有的属性必须被赋值 5、 所有的特殊符号都用编码表示,例如小于号必须被编码为“<” 6、 不要在注释内容中使用“--”, “--”只能出现在XHTML注释的开头和结结。 7、 XHTML规范废除了name属性,而使用id属性作为统一的名称。 |
| ||||
Content
|
Chapter 2 CSS standardization and CSS framework
1. CSS document coordination and coding standards1. CSS document coordination:
代码的注释规范 |
/*d1注释说明*/ #id1{ } #id1 .class{ } /* id2注释说明*/ #id2{ } #id2 .class{ } |
CSS Document Coordination (Product Category) | ||
1. Reset style sheet: Reset Set the browser style
3. Module style sheet: the formulation of small module and small section style sheets. |
CSSDocument coordination (publish page class )
|
1. Reset the browser style, page common layout style, small modules, small The section style sheet is all written into one file called style.css.
|
Each section is explained with comments, which provides great convenience for future maintenance.
Code comment specifications | ||
/*d1 comment description*/ #id1{ } #id1 .class{ }
/* id2 comment description*/ #id2{ }#id2 .class{ } |
布局常用名称: | |||
名称 | 说明 | 名称 | 说明 |
wrap | 外套 | container | 容器 |
site | 站点 | content | 内容块 |
nav | 导航 | column | 栏 |
main | 主体 | left | 左 |
layout | 布局 | center | 中 |
sidebar | 侧栏 | right | 右 |
Organize by priority relationship |
First step : If necessary, first declare layout attributes (determine the display of elements), such as these attributes: float display position … Step 2: Declare the box model attributes (determine the shape of the element) if necessary, such as these attributes: width height margin padding border background… Step 3: Finally declare the layout attributes (to determine the content display of the element) if necessary, such as these attributes: color font font-size font-weight text-align… |
CSSNaming Rules | 1. Be case-sensitive: use all lowercase letters when naming CLASS and ID 2. Pay attention to legality: CSS names start with letters and can be connected with numbers, letters, Underline, connector. 3. The semantic definition is clear and easy to understand: CSS naming keywords must convey the meaning, and the name should reflect the purpose and related information, and should be brief and do not include any redundant information. |
Common layout names: | |||
Name | Description | Name | Description |
wrap | Coatcontainer | Container | |
site | site | content | content block |
nav | navigation | column | column |
main | main | left | left |
layout | td>layout | center | center |
sidebar | sidebar | right | Right |
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Name
| Description | Name | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
logo | logo | banner | advertising banner | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
login | Login | loginbar | Login bar | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
regsiter | Register | search | Search | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
shop | Shopping cart | list | list | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
tool/toolbar | Toolbar | service | Service | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
tab | tab | hot | Hotspot | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
source | Resource | td>news | news | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
site_map | Sitemap | download | Download | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
about_us | About us | copyright | Copyright | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
partner | Partner | friendlink | Friendly link | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
guide | Guide | vote | Vote | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
joinus | Join | header | Header | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
footer | footer | homepage | Homepage |
Class commonly used Name: | |||
Name | Description | Name | Description |
title | title | current | current |
label | label | td>spec | Special |
note | Annotations | red | red |
summary | Summary | submit | Submit |
msg | Prompt message | textbox | text box |
status | status | drop | drop |
tips | Tips | btn | Button | tr>
scroll | scroll | form | form |
icon | icon | count | statistics |
arr/arrow | Arrows | crumb | Navigation |
cor/corner | Corner/Rounded Corner | breadcrumb | Navigation Tips |
Navigation common name:
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Name | Description | Name
| Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
nav | Navigation
| menu
| Menu
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
mainnav/globalnav | Main navigation | topnav | Top navigation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
subnav | subnav | sidebar | Side navigation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
leftsidebar | left navigation | rightsidebar | right navigation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
submenu | Submenu | dropmenu | drop menu td> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
sidebaricon | side navigation icon | menucontainer | Menu container |
Common file names: | |||
Name | Description | Name | Description |
master.css | main file | themes.css | Main file |
layout.css | Layout, layout files | base.css | Basic public files |
columns.css | column file | module.css | Module file |
font.css | Text style file td> | forms.css | Form file |
print.css | Print style file | mend.css | Patch file |
CSS Reset |
html , body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em , font, img, ins, kbd, q, s, samp, small, strike, sub, sup, tt, var, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption , tbody, tfoot, thead, tr, th, td { margin: 0; padding: 0; border: 0; outline: 0; font-weight: inherit; font-style: inherit; font-size: 100%; font- family: inherit; vertical-align: baseline; } :focus { outline: 0; } a img, iframe { border: none; } ol, ul { list-style: none; } input, textarea, select, button { font-size: 100%; font-family: inherit; } select { margin: inherit; } /* Fixes incorrect placement of numbers in ol's in IE6/7 */ ol { margin-left:2em; } |
ClearFix CSS code |
/* == clearfix == */ .clearfix:after { /*/*/ content: "."; /* IE8 hack */ display: block; height: 0; clear: both; visibility: hidden; } /* IE7 hack */ .clearfix { display: inline-block; } /* IE-mac, IE5, IE6 */ * html .clearfix { height: 1%; } .clearfix { display: block; } |
| ||
文档结构规范 |
Chapter 3 General Specifications
| ||
Images切图规范 |
1、 采用jpg、gif、png作为切图输出格式。 2、 切图图片大小根据具体项目制定,要求尽量优化图片。 3、 CSS背景图片输出为PNG 8。PNG 8除了不支持动画外,PNG8有GIF所有的特点,但是比GIF更加具有优势的是它支持alpha透明和更优的压缩。所以,大多数情况下,都应该用 PNG8不是GIF(除了非常小的图片GIF会有更好的压缩外)。 4、 同类型的图片进行CSS Sprites优化。减少http请求。 |
1. Style file naming convention:
For details on Style file naming convention, see Chapter 2
| ||
1. CSS cutting files follow the following naming convention: (XXX is a custom name) l b01.png l b02. png l … l bN.png 2. Other photo images on the page refer to images with absolute addresses and will not be cut. |
ImagesImage cutting specifications |
1. Use jpg, gif, and png as cut image output formats. 2. The size of the cut image is determined according to the specific project, and it is required to optimize the image as much as possible. 3. The CSS background image is output as PNG 8. PNG 8 has all the features of GIF except that it does not support animation, but it has more advantages than GIF in that it supports alpha transparency and better compression. Therefore, in most cases, PNG8 should be used instead of GIF (except for very small images, GIF will have better compression). 4. Optimize CSS Sprites for images of the same type. Reduce http requests. |
JavascriptStandards |
1. Unify the jquery framework to establish common JavaScript libraries and usage documents 2. Js naming convention: jquery-XXXX.pack.js (XXXX is the name of the custom function module) |
Chapter 4 project production completed
1. Organize CSS code and optimize document structure:
l selector Write on the top line, all attributes are in one line;
l Use external style sheets, try not to use