google编码规范之htmlcssguide.html其一

2022/2/8 6:15:08

本文主要是介绍google编码规范之htmlcssguide.html其一,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

一.背景

This document defines formatting and style rules for HTML and CSS. It aims at improving collaboration, code quality, and enabling supporting infrastructure. It applies to raw, working files that use HTML and CSS, including GSS files. Tools are free to obfuscate, minify, and compile as long as the general code quality is maintained.

对于HTML和CSS,这些文档定义了格式和样式规则。他目的是在提升协作、代码质量和能够支持基本设施。它应用于使用HTML和CSS原始的的工作文件夹,包括GSS文件夹。只要维持一般的代码质量,工具就可以自由的去模糊、缩小和编译。

---------------------------------------------不认识单词---------------------------------------------------------------------

document:文档;记录            defines:定义            formatting:格式化              style:样式

aims:目的;目的是      collaboration:合作;协作       code:代码       infrastructure:基础设施

applies:应用;申请                raw:未经加工的;原始的                     files:文件夹

obfuscate:混淆;模糊不清           minify:缩小            compile:编译                                   

as long as:只要               maintained:维持;保持

---------------------------------------------------------------------------------------------------------------------------------

二.普遍的

2.1 General Style Rules 普遍的样式风格

2.1.1 Protocol 协议

Use HTTPS for embedded resources where possible.

Always use HTTPS (https:) for images and other media files, style sheets, and scripts, unless the respective files are not available over HTTPS.

尽可能的对于嵌入式资源使用HTTPS。

对于图像和其他的媒体文件,样式表和笔迹经常使用HTTPS (https:) ,除非各自的文件不可用在HTTPS之上。

---------------------------------------------不认识单词---------------------------------------------------------------------

embedded:嵌入            resources :资源;资料            media:媒体           sheets:一张;薄片 scripts:笔迹;剧本        respective:分别的                   available:可用

---------------------------------------------------------------------------------------------------------------------------------

2.2 General Formatting Rules 普遍的格式风格

2.2.1 Indentation 首行缩进

Indent by 2 spaces at a time.

Don’t use tabs or mix tabs and spaces for indentation.

每次缩进两个空格。

首行缩进时不要使用制表符或者混合制表符和空格。

--------------------------------------------------不认识的单词-------------------------------------------------------------

Indent:缩进 at a time:每次

---------------------------------------------------------------------------------------------------------------------------------

2.2.2 Capitalization 用大写,资本化

Use only lowercase.

All code has to be lowercase: This applies to HTML element names, attributes, attribute values (unless text/CDATA), CSS selectors, properties, and property values (with the exception of strings).

只使用小写。

所有的代码必定是小写:这是应用于HTML的要素名称,属性,属性值(除非文本/CDATA),CSS的选择器,特性,和特性值(字符串例外)

--------------------------------------------------不认识的单词-------------------------------------------------------------

lowercase:小写 have to be:必定是 element:要素 attributes:属性;性质 selectors:选择器 properties:特性 with the exception of:除...外 strings:字符串;一系列

---------------------------------------------------------------------------------------------------------------------------------

2.2.3 Trailing Whitespace 尾随空格

Remove trailing white spaces. Trailing white spaces are unnecessary and can complicate diffs.

移动尾随的空格。 尾随空格是不必要的和复杂的差别。

--------------------------------------------------不认识的单词-------------------------------------------------------------

Trailing:后面的          Whitespace:空格,空白符               unnecessary:不必要的,多余的 complicate:复杂化

---------------------------------------------------------------------------------------------------------------------------------

2.3 General Meta Rules 普遍的标签风格

2.3.1 Encoding 编码,字符编码

Use UTF-8 (no BOM).

Make sure your editor uses UTF-8 as character encoding, without a byte order mark.

Specify the encoding in HTML templates and documents via <meta charset="utf-8">. Do not specify the encoding of style sheets as these assume UTF-8.

(More on encodings and when and how to specify them can be found in Handling character encodings in HTML and CSS.)

使用UTF-8 编码(不需要BOM表明字节顺序)

确保编辑器使用UTF-8作为字符编码,不是一个字节顺序标记。

在HTML模板和文件通过<meta charset="utf-8">具体说明编码。

没有具体说明的编码样式表作为这个假定的UTF—8。

(更多的编码信息何时,以及如何去具体说明更多的编码信息,能够在HTML和css的操作特性里找到)

---------------------------------不认识的单词------------------------------------------------------------------------------

UTF逐渐成为电子邮件、网页及其他存储或传送文字的应用中,优先采用的编码

BOM:Byte Order Mark 节序标记     editor:编辑      Specify :具体说明       encoding:编码

templates :模板          documents:文件          via:通过

---------------------------------------------------------------------------------------------------------------------------------

2.3.2 Comments    注解

Explain code as needed, where possible.

Use comments to explain code: What does it cover, what purpose does it serve, why is respective solution used or preferred?

(This item is optional as it is not deemed a realistic expectation to always demand fully documented code. Mileage may vary heavily for HTML and CSS code and depends on the project’s complexity.)

在可能的情况下,根据需要解释代码。

使用注解来解释代码:它包括了什么,它提供了什么用途,为什么是用各自习惯的或者更喜欢的解决方案?

这个选项是可选择的,因为它不强烈要求完整的文件代码。对于HTML和CSS代码的用处或许不同,取决于项目的复杂程度。

--------------------------不认识的单词--------------------------------------

purpose:目的    respective:各自的    realistic:切实可行的   


2.3.3 Action Items    动作项

Mark todos and action items with TODO.

Highlight todos by using the keyword TODO only, not other common formats like @@.

Append a contact (username or mailing list) in parentheses as with the format TODO(contact).

Append action items after a colon as in TODO: action item.

标记所有的动作项到待办的事。

只使用关键词来强调显示全部内容,而不是用常见的格式,如@@。

在圆括号中附加一个联系人(用户名或者邮件列表),例如格式TODO(联系人)。

在冒号后面附加动作项,例如TODO:动作项。

-------------------不认识的单词------------------------------------------------------

todos:全部      TODO:待办事项       Highlight:强调    common formats:常见格式

Append:附加       mailing list:邮件列表    parentheses:圆括号     colon:冒号



这篇关于google编码规范之htmlcssguide.html其一的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程