Develop good CSS coding habits in Web page making

Source: Internet
Author: User
Tags character set
css| Code | Web page

  1. Select the correct character set for CSS.

This problem may not arouse the attention of many people, but in the process of website development, I found it is very important to select the correct character set for CSS, if your Web page is using GB2312, then add a @charset "gb2312" to the top of the CSS file. This can ensure that the CSS and Web pages to maintain the same character set, if the page is using Utf-8, then the top of the CSS file plus @charset "Utf-8";

  2. Correctly plan CSS

Typically, I'll define some common styles in the beginning of the CSS file, as in the following example:

Body {font:12px Arial, Helvetica, Sans-serif;color: #000; background: #fff;p adding:0px;margin:0px;text-align:center;}
div,form,img,ul,ol,li,dl,dt,dd,p {margin:0;padding:0;border:0;}
Ul{float:left;}
Li{list-style:none;}
a{Text-decoration:none;}

This has become a habit of me, the Web page commonly used elements of the basic style definition, encountered a special situation and redefined, which can greatly reduce the size of the CSS file, but also more conducive to the maintenance of CSS.

  3. Learn to use CSS abbreviation syntax

I suggest you take a look at this article common CSS abbreviation syntax summary



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.