search
HomeWeb Front-endHTML TutorialA little experience of html and css architecture_html/css_WEB-ITnose

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.

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Difficulty in updating caching of official account web pages: How to avoid the old cache affecting the user experience after version update?Difficulty in updating caching of official account web pages: How to avoid the old cache affecting the user experience after version update?Mar 04, 2025 pm 12:32 PM

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,

How do I use HTML5 form validation attributes to validate user input?How do I use HTML5 form validation attributes to validate user input?Mar 17, 2025 pm 12:27 PM

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

What are the best practices for cross-browser compatibility in HTML5?What are the best practices for cross-browser compatibility in HTML5?Mar 17, 2025 pm 12:20 PM

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

How to efficiently add stroke effects to PNG images on web pages?How to efficiently add stroke effects to PNG images on web pages?Mar 04, 2025 pm 02:39 PM

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

What is the purpose of the <datalist> element?What is the purpose of the <datalist> element?Mar 21, 2025 pm 12:33 PM

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

How do I use the HTML5 <time> element to represent dates and times semantically?How do I use the HTML5 <time> element to represent dates and times semantically?Mar 12, 2025 pm 04:05 PM

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

What is the purpose of the <progress> element?What is the purpose of the <progress> element?Mar 21, 2025 pm 12:34 PM

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

What is the purpose of the <meter> element?What is the purpose of the <meter> element?Mar 21, 2025 pm 12:35 PM

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

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

MinGW - Minimalist GNU for Windows

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

Dreamweaver CS6

Visual web development tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!