Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What don't you do in CSS development

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "what do not do in CSS development". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "what do not do in CSS development".

1. Do not abuse the class

Use ID instead of classes where it makes sense. This is a way to enable browsers to access DOM elements faster.

two。 Don't throw everything into one CSS file

Partition CSS makes it easier to manage. Each CSS file can be decomposed into logical components such as header.css, footer.css, and so on.

3. Do not name the selector ".red-with-green-dashed-lines" (red and green dotted lines)

Name your selector according to the components on the page. For example, "header-left", "content-title" or "content-date" are more descriptive.

4. Don't forget to comment.

Annotations are important in CSS to understand how each style is associated with other styles and what color scheme applies to which components.

5. Don't be afraid of development tools.

Each browser now has its own set of development tools, usually by pressing F12. These tools are critical when "debugging CSS".

6. Don't be afraid to cover

Of course, CSS frameworks, such as Bootstrap and Foundation, are huge, but each needs to be adapted to your needs. When you get an updated framework, it will overwrite your changes. Instead of digging deep into the huge CSS file, you might as well create an bootstrap-overrides.css file and adjust the framework according to your wishes, just...

7. Don't abuse it! It's important.

The overall idea of CSS is to "cascade" styles from one to another. ! The point is to remember that demining is the same as stepping through all previous styles. : -)

8. Do not use a large number of web fonts

This is also obvious, but some people just like to make their own typesetting. Use only one or two (up to three) web fonts on the site, and then return to the browser default settings to keep the site optimized.

9. Do not manually encode all CSS

To maintain the DRY of CSS, you can use a CSS preprocessor such as LESS or SASS. The advantage of using these preprocessors is that you can define variables, such as a color scheme above, and then reuse all CSS without having to track each color when you need to modify it.

10. Don't make CSS too "bloated"

Spaces take up space in the CSS file. Since we all want our CSS to load quickly, we use the CSS compression tool to lose weight before deploying to the site.

Thank you for reading, the above is the content of "what not to do in CSS development". After the study of this article, I believe you have a deeper understanding of what not to do in CSS development, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report