Google html/CSS code style guide

Source: Internet
Author: User
ArticleDirectory
    • Remarks

Google today released the HTML/CSS code Style Guide (Google html/CSS style guide). In fact, this is not a complete set of development specifications. We can think of it as a simple development suggestion.

Like Google JavaScript style guide I mentioned in "using Google closure Linter to verify JavaScript code", this document can only contain a small amount of content, and I have finished reading it in less than an hour, from this shortCodeThe Style Guide finds some interesting content. I will list two items below.

Resource file omitted Protocol

We recommend that you omit the protocol section in images, media files, styles, and script URLs (HTTP:,Https:). After the protocol is omitted, the resource file inherits the protocol of the page url. this not only prevents mixed content, but also reduces the page size. for example, you can reference a Javascript file in the following recommended method.

Omit optional labels

Those who have used dreamwave should be impressed. When you create an HTML file, the default code is as follows.

 
<HTML>  

We willTitle, External CSS and JavaScript references are placed inHeadArea where the content displayed on the page is placedBodyBut in factHtml,HeadAndBodyAll labels can be omitted.

After deleting these optional tags, it looks strange, but the page is displayed normally, and W3C detection can also pass. I have already done this on my blog. note that if you want to write pages in XHTML, keepHtmlTag, because you still need the following code as a declaration.

 
<HTML xmlns = "http://www.w3.org/1999/xhtml">
Remarks

Google's HTML/CSS code style guide is a short and concise manual for coding the builders. It is useful, but do not be superstitious. for example, if there is one item in it, we suggest using two spaces as indentation. In many teams, it may not be feasible. Now our team uses tab.

Many HTML recommendations in this manual are for HTML5, but here the HTML style is used instead of the XHTML style. In many cases, code readability is actually impaired to omit the code, you should judge the trade-off.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.