Google HTML/CSS 风格指南
1、Background 背景
本文档定义了 HTML 和 CSS 的格式和样式规则。它旨在 改善协作、代码质量并启用支持基础设施。 它适用于使用 HTML 和 CSS 的原始工作文件,包括 GSS 文件。 工具可以自由地混淆、缩小和编译,只要通用代码 保持质量。
2、常规
2.1、一般样式规则
2.1.1、Protocol 协议
尽可能对嵌入式资源使用 HTTPS。除非相应的文件无法通过HTTPS获取,否则始终使用HTTPS(https:)来加载图像和其他媒体文件、样式表和脚本。
/* Not recommended: omits the protocol */ @import '//fonts.googleapis.com/css?family=Open+Sans'; /* Not recommended: uses HTTP */ @import 'http://fonts.googleapis.com/css?family=Open+Sans'; /* Recommended */ @import 'https://fonts.googleapis.com/css?family=Open+Sans';
2.2、常规格式规则
2.2.1、缩进
一次缩进 2 个空格。不要使用制表符或混合使用制表符和空格进行缩进。
.example { color: blue; }
- Fantastic
- Great
2.2.2、Capitalization
仅使用小写字母。属性值(除非 text/CDATA所有代码都必须是小写的:这适用于 HTML 元素名称、属性、 CSS 选择器、属性和属性 值(字符串除外)。
Home
/* Not recommended */ color: #E5E5E5; /* Recommended */ color: #e5e5e5;
2.2.3、尾随空格
删除尾随的空格。尾随空格是不必要的,并且会使差异复杂化。
What?_
Yes please.
2.3、通用 Meta 规则
2.3.1、Encoding 编码
使用 UTF-8(无 BOM)。请确保您的编辑器使用 UTF-8 作为字符编码,并且不使用字节顺序标记。
通过 All recommendations All recommendations The currency symbol for the Euro is “&eur;”. The currency symbol for the Euro is “€”. … … Sign in Sign in
文章版权声明:除非注明,否则均为主机测评原创文章,转载或复制请以超链接形式并注明出处。