8 simple and practical CSS tips

Source: Internet
Author: User

#1. Structure
Keeping the CSS structure clear not only helps to keep the CSS file simple, but also facilitates future checks and changes.

#2. Keep it concise
PersistenceCodeIt is concise and can greatly reduce the size of CSS files.

#3. Padding vs. Margin
For browsers, margin is the most compatible attribute. Therefore, the padding attribute should be used whenever possible as long as conditions permit.

#4. Integration
In the following example, a public class is defined to replace the same code used in different places: Color: Gray.

#5. Notes
Adding a simple comment at a proper position not only helps you understand the code, but also helps others understand your code.

#6. Verify
It is best to verify the created CSS file to help you find the errors in the file.

#7. Avoid using styles in XHTML
Do not use styles in XHTML code. This not only increases the size of webpage files, but also makes the code messy and complex.

#8. Name
Use standard IDs and class names that can be understood literally, not just code names.

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.