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

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.