Web encoding Specification

Source: Internet
Author: User
Tags closing tag

HTML syntax
    • Use two spaces instead of tabs (tab)-This is the only way to ensure consistent presentation in all environments.
    • Nested elements should be indented one time (that is, two spaces).
    • For the definition of a property, make sure to use double quotes and never use single quotes.
    • Do not add a slash at the end of the self-closing (self-closing) element-The HTML5 specification explicitly describes this as optional.
    • Do not omit the optional end tag (closing tag) (for example, </li> or </body> ).
<!DOCTYPE HTML><HTML>  <Head>    <title>Page Title</title>  </Head>  <Body>    <imgsrc= "Images/company-logo.png"alt= "Company">    <H1class= "Hello-world">Hello, world!.</H1>  </Body></HTML>
HTML5 DOCTYPE

Adding a standard mode declaration to the first line of each HTML page ensures a consistent representation in every browser.

<! DOCTYPE HTML > < HTML >  < Head >  </ Head > </ HTML >
CSS syntax
    • uses two spaces instead of tabs (tab)-This is the only way to ensure consistent presentation in all environments. When
    • groups selectors, separate selectors are placed on a single line.
    • for readability of the code, add a space before the left curly brace of each declaration block. The right curly brace of the
    • declaration block should be taken separately.
    • a space should be inserted after each declaration statement's : .
    • to obtain more accurate error reporting, each declaration should have a single row.
    • All declaration statements should end with a semicolon. The semicolon after the last declaration statement is optional, but if you omit the semicolon, your code may be more prone to errors.
    • for comma-separated property values, you should insert a space after each comma (for example, Box-shadow ).
    • do not rgb () , Rgba () , HSL () , Hsla () , or rect () Insert a space after the comma of the inner of the value. This makes it easy to distinguish multiple color values (with commas and no spaces) from multiple attribute values (plus commas and spaces).
    • for property values or color parameters, omit 0 (for example, . 5 instead of 0.5 ; -.5px instead of -0.5px ) before decimals less than 1. The
    • hexadecimal value should be all lowercase, for example, #fff . When you scan a document, lowercase characters are easy to distinguish because their form is easier to distinguish.
    • use shorthand hexadecimal values as much as possible, for example, #fff instead of #ffffff .
    • adds double quotation marks to the properties in the selector, for example, input[type= "text"] . Only in some cases is optional, but for code consistency, it is recommended that you add double quotes.
    • avoid specifying units for 0 values, for example, margin:0; instead of margin:0px; .

Do you have any questions about the terminology used here? Refer to the syntax section of the cascading Style Sheets article on Wikipedia.

/*Bad CSS*/. Selector,. Selector-secondary,. Selector[type=text]{padding:15px;margin:0px 0px 15px;Background-color:rgba (0, 0, 0, 0.5);Box-shadow:0px 1px 2px #CCC, inset 0 1px 0 #FFFFFF}/*Good CSS*/. Selector,.selector-secondary,.selector[type= "text"]{padding:15px;Margin-bottom:15px;Background-color:Rgba (0,0,0,.5);Box-shadow:0 1px 2px #ccc, inset 0 1px 0 #fff;}

Web encoding Specification

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.