CSS itself can be said to be a very simple and easy to get started language. To create a page or a small business website, the CSS requirements are very low. As long as you are familiar with grammar and guess the meaning of English words, you can basically spell out a set of patterns. What’s more, there are a variety of auxiliary software on the market.
If it is a relatively large website, the requirements for CSS architecture will be relatively high. For example, there are some public parts that can be extracted and made into modules. This is called modularity.
What are the advantages of modularity?
Without going through various Google results, the main things that come to my mind are the following:
1. Reduce meaningless development work There is no need to copy and paste a certain style code into other files.
2. The code is easy to maintain. If the module style changes, you only need to modify a css file.
3, with the corresponding comments and directory structure, the html and css code of the entire project will look clearer.
But modularization is sometimes very confusing.
In the actual process of developing and maintaining a website, the modules provided by html are usually maintained according to functions. However, the so-called modularization of CSS refers to modules based on UI presentation, and the standard for dividing modules is not uniform.
For the organization of css itself, we would like to divide modules according to css. But for html, including when providing it to downstream departments for development, of course the html module must be provided. They don't care about how CSS is divided and integrated.
So, I came up with the following idea:
css is divided into 5 layers of structure
The base layer?? is some basic styles and basic module style layers common to the entire site (I include Qing 0 here). This layer is equivalent to dividing modules according to UI presentation. If you cooperate with good UI specifications, you can also ensure that the basic module UI of the entire site is consistent. For large websites, this should be guaranteed by professional UI design. If it's reliable, the base layer can even be developed into a website's style core package.
The module layer?? is the functional module style layer. This part of css is composed of basic module style and non-public style.
patch layer?? is the patch layer. When using functional modules to combine pages, put margins and other styles that cannot be included in modules in patches. (For example, a page suddenly requires adding a banner)
pages layer?? It is a style sheet file that uses the import method to introduce things from the module layer and patch layer to the page. . With the help of software that can merge css (you can search for some by searching the keyword "Merge" on Google), compress all imported files into this pages file and put them online.
tag layer ?? The top tag is equivalent to the css code that is actually compressed and launched online, and does not consume development costs. This basically ensures that there is only one http request for each page's css. It can also meet local modular development.
The corresponding structure of html
html is equivalent to being divided into 4 layers.
base layer ?? Corresponds to the base layer of css. It is a reference file for the entire UI standard style and standard style HTML code.
Module layer?? Corresponds to the module layer of css. It can be provided to other developers, and all the status of the module must be written in it. This not only ensures that backend developers can easily find the code for a certain function, but also solves the problem of sometimes sacrificing part of the state to provide a complete page. For example, a button has two states. If they are placed on the page, the page will be easily distorted. If it is not placed on the page, it will be inconvenient for backend engineers to develop. Of course, I used to write comments on other states on the page, but there is still a problem, that is, I often need to repeat the meaningless labor of commenting/uncommenting.
The pages layer is the assembled pages. Since the module has provided specific code to the backend engineers, what does the pages do? Its purpose is to tell yourself and others where each module needs to be placed. A macro preview is also provided. It’s always frustrating to not have a preview!
dev layer?? Actually, this is purely for development. Various backend languages have includes that can be used to manage common modules. But html does not. For this reason, DW also provides a template function that is both powerful and cheating. But it feels like few people use it. I don’t know if it’s because the operation is complicated? Not flexible? Or is it because a bunch of comments were generated? Looks vulgar? I don’t know, I don’t have one anyway. Fortunately, xxx people helped develop a local program to solve the include problem of html. The files in the dev directory are written according to the syntax requirements of this program. Given a url address under a module, the html code is automatically merged to generate files under pages.

The official account web page update cache, this thing is simple and simple, and it is complicated enough to drink a pot of it. You worked hard to update the official account article, but the user still opened the old version. Who can bear the taste? In this article, let’s take a look at the twists and turns behind this and how to solve this problem gracefully. After reading it, you can easily deal with various caching problems, allowing your users to always experience the freshest content. Let’s talk about the basics first. To put it bluntly, in order to improve access speed, the browser or server stores some static resources (such as pictures, CSS, JS) or page content. Next time you access it, you can directly retrieve it from the cache without having to download it again, and it is naturally fast. But this thing is also a double-edged sword. The new version is online,

The article discusses using HTML5 form validation attributes like required, pattern, min, max, and length limits to validate user input directly in the browser.

Article discusses best practices for ensuring HTML5 cross-browser compatibility, focusing on feature detection, progressive enhancement, and testing methods.

This article demonstrates efficient PNG border addition to webpages using CSS. It argues that CSS offers superior performance compared to JavaScript or libraries, detailing how to adjust border width, style, and color for subtle or prominent effect

The article discusses the HTML <datalist> element, which enhances forms by providing autocomplete suggestions, improving user experience and reducing errors.Character count: 159

This article explains the HTML5 <time> element for semantic date/time representation. It emphasizes the importance of the datetime attribute for machine readability (ISO 8601 format) alongside human-readable text, boosting accessibilit

The article discusses the HTML <progress> element, its purpose, styling, and differences from the <meter> element. The main focus is on using <progress> for task completion and <meter> for stati

The article discusses the HTML <meter> element, used for displaying scalar or fractional values within a range, and its common applications in web development. It differentiates <meter> from <progress> and ex


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

WebStorm Mac version
Useful JavaScript development tools

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Dreamweaver CS6
Visual web development tools

Atom editor mac version download
The most popular open source editor

SublimeText3 English version
Recommended: Win version, supports code prompts!
