HTML5 Coding Specification

Source: Internet
Author: User

    • Adding a standard mode declaration to the first line of each HTML page ensures a consistent representation in every browser.
    • 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> ).
    • In the introduction of CSS and JavaScript files, It is generally not necessary to specify type properties, because text/css and text/javascript respectively, their default values.
    • A Boolean property can be declared without assigning a value. The XHTML specification requires that it be assigned a value, but the HTML5 specification does Not.
1 <!DOCTYPE HTML>2 <HTMLLang= "zh-cn">3   <Head>4     <title>Page Title</title>5   </Head>6   <Body>7     <imgsrc= "images/company-logo.png"alt= "company">8     <H1class= "hello-world">Hello, world!.</H1>9   </Body>Ten </HTML>

HTML attributes should be arranged in the order given below to ensure readability of the Code.

    • class
    • id,name
    • data-*
    • src, for, type,href
    • title,alt
    • aria-*,role

Class is used to identify highly reusable components and should therefore be ranked First. ID is used to identify specific components and should be used with caution (for example, bookmarks within a page), so it is ranked Second.

1 <aclass="..."ID="..."Data-modal= "toggle"href="#">2 Example Link3 </a>4 5 <inputclass= "form-control"type= "text">6 7 <imgsrc="..."alt="...">
1 <inputtype= "text"Disabled>2 3 <inputtype= "checkbox"value= "1"checked>4 5 <Select>6   <optionvalue= "1"selected>1</option>7 </Select>

HTML5 Coding 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.