8 Practical CSS Tips

Source: Internet
Author: User
Here's a list of simple and practical ways to help you improve your CSS stylesheets, and if you're just starting to use CSS, this log will help you better understand CSS.

Here's a list of simple and practical ways to help you improve your CSS stylesheets, and if you're just starting to use CSS, this log will help you better understand CSS.

#1. Structure

Keep the CSS structure clear, not only help to keep the CSS file simple, but also conducive to future inspection, change.

#2. Keep it simple

Keeping your code simple can drastically reduce the size of your CSS file.

#3. Padding vs. Margin

For browsers,Margin is one of the worst compatibility attributes. Therefore, you should use the Padding property as much as possible if the conditions permit.

#4. Integration

In the following example, a common class is defined to replace the same code that is used in different places:Color:grey.

#5. Comments

Adding a simple annotation in the right place will not only help you understand the code, but others will also be able to understand your code well.

#6. Verify

It's a good idea to validate a CSS file that has already been created to help you find errors in your files. The Consortium CSS Authentication Service

#7. Avoid using styles in XHTML

Do not use styles in XHTML code, which not only increases the size of your Web page files, but also makes your code confusing and complex.

#8. Named

Use a standard ID and class name that you can literally understand correctly, not just code names.



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.