The article organizes various CSS specifications in Web front-end development, including file specifications, annotation specifications, naming specifications, writing specifications, testing specifications, etc.
1. File specifications
1. Files are archived in the agreed directory.
Specific requirements are explained through Douban’s CSS specifications:
All CSS is divided into two categories: general categories and business categories. Common CSS files are placed in the following directories:
Business CSS refers to files related to specific products and is placed in the following directory:
Outbound CSS files are suitable for large files that are common to the entire site and product level. Inline CSS files are suitable for CSS that is shared across one or several pages. Another pair of specific CSS documents are organized. For example:
2. File introduction can be done externally or inline.
Both link and style tags should be placed in the head. In principle, writing styles directly on html is not allowed. Avoid using @import in CSS and do not nest it more than one level.
3. File name, file encoding and file size
2. Comment specifications
1. Comments at the top of the file (recommended)
- /*
- * @description: Chinese description
- * @author: name
- * @update: name (2013 -04-13 18:32)
- */
2. Module comments
- /* module: module1 by Zhang San*/
- …
- /* module: module2 by Zhang San*/
Module comments must be written on a separate line
3. Single-line comments and multi-line comments
/* this is a short comment */
Single-line comments are OK It can be written on a separate line or at the end of the line. The length of each line in the comment should not exceed 40 Chinese characters or 80 English characters.
/*
* this is comment line 1.
* this is comment line 2.
*/
Multi-line comments must be written on separate lines
4. Special comments
/* TODO: xxxx by name 2013-04-13 18:32 */
/* BUGFIX: xxxx by name 2012-04- 13 18:32 */
Used to mark modifications, to-do and other information
5. Block comments
- /* Header */
- /* Footer */
- /* Gallery */
Comment a code block Optionally, block the style statement and comment it on a new line.
3. Naming conventions
Use meaningful or generic ID and class naming: ID and class naming should reflect the function of the element or use a generic name instead of Abstract obscure naming. It is preferred to reflect the purpose of use of the element; using a common name means that the element does not have a specific meaning and is no different from its sibling elements, and is usually used for auxiliary naming; using functional or common names can be more suitable for document or template changes. .
Commonly used names (memorize more and look up English words): page, wrap, layout, header (head), footer (foot, ft), content (cont), menu, nav, main, submain, sidebar (side), logo, banner, title (tit), popo (pop), icon, note, btn, txt, iblock, window (win), tips, etc.
The shorter the ID and class names are, the better, as long as they are enough to express the meaning. This not only helps with understanding, but also improves code efficiency.
Type selection Avoid using labels, IDs, and classes at the same time as selectors to locate an element; from performance considerations, the selector hierarchy should also be reduced as much as possible.
Points to note when naming:
1. Common id naming:
(1) Page structure
(2) Navigation
(3) Functions
2. Naming of commonly used classes:
(1) Color :Use the color name or hexadecimal code, such as
(2) Font size, directly use "font font size" as the name, such as
(3) Alignment style, use the English name of the alignment target, such as
(4) Title bar style, named using the "category function", such as
4. Writing specifications
1. Typesetting specifications
(1) Use 4 spaces instead of Use tabs or mixed space tabs as indents;
(2) Rules can be written in a single line or multiple lines, but the rule formatting in the entire file must be uniform;
Single-line formatting style Constraints
Typesetting constraints of multi-line writing style
2. Attribute writing order
3. Rule writing Specifications
4. Code performance optimization
5. Use of CSS Hack
Please don’t use browser detection and CSS Hacks all the time, try other solutions first! Considering the efficiency and manageability of the code, although these two methods can quickly resolve browser parsing differences, they should be regarded as a last resort. In a long-term project, allowing hacks will only lead to more hacks, and the more you use it, the more you will rely on it!
It is recommended to use the following:
6. Font rules
5. Other specifications
6. Test specifications
1. Understand browser special effects support
For page performance considerations, if the browser does not support CSS3 related attributes, then a certain function of the browser Some special effects will no longer be supported. The support status of attributes is shown in the following table (Y means supported, N means not supported):
2. Set browser support standards
3. Commonly used style testing tools
W3C CSS validator: http://jigsaw.w3.org/css-validator/
CSS Lint: http://csslint.net/
CSS Usage: https://addons.mozilla .org/en-us/firefox/addon/css-usage/

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.

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

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

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

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

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


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

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SublimeText3 Linux new version
SublimeText3 Linux latest version

Notepad++7.3.1
Easy-to-use and free code editor

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

Dreamweaver CS6
Visual web development tools
