MindMap Gallery Front-end html css code specification
There are some normative issues that need to be paid attention to when writing front-end code.
Edited at 2021-03-20 18:19:17This is a mind map about bacteria, and its main contents include: overview, morphology, types, structure, reproduction, distribution, application, and expansion. The summary is comprehensive and meticulous, suitable as review materials.
This is a mind map about plant asexual reproduction, and its main contents include: concept, spore reproduction, vegetative reproduction, tissue culture, and buds. The summary is comprehensive and meticulous, suitable as review materials.
This is a mind map about the reproductive development of animals, and its main contents include: insects, frogs, birds, sexual reproduction, and asexual reproduction. The summary is comprehensive and meticulous, suitable as review materials.
This is a mind map about bacteria, and its main contents include: overview, morphology, types, structure, reproduction, distribution, application, and expansion. The summary is comprehensive and meticulous, suitable as review materials.
This is a mind map about plant asexual reproduction, and its main contents include: concept, spore reproduction, vegetative reproduction, tissue culture, and buds. The summary is comprehensive and meticulous, suitable as review materials.
This is a mind map about the reproductive development of animals, and its main contents include: insects, frogs, birds, sexual reproduction, and asexual reproduction. The summary is comprehensive and meticulous, suitable as review materials.
Code specifications
HTML specification
HTML5 standard template
<!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="UTF-8"> <title>HTML5 standard template</title> </head> <body> </body> </html>
Page language lang
<html lang="zh-CN">
More regional language references:
zh-SG Chinese (Simplified, Singapore) corresponds to cmn-Hans-SG Mandarin (Simplified, Singapore)
zh-HK Chinese (Traditional, Hong Kong) corresponds to cmn-Hant-HK Mandarin (Traditional, Hong Kong)
zh-MO Chinese (Traditional, Macau) corresponds to cmn-Hant-MO Mandarin (Traditional, Macau)
zh-TW Chinese (Traditional, Taiwan) corresponds to cmn-Hant-TW Mandarin (Traditional, Taiwan)
charset character set
<meta charset="UTF-8">
Try to write it as standard "UTF-8" instead of "utf-8" or "utf8" or "UTF8"
writing style
HTML code case
HTML tag names, class names, tag attributes and most attribute values must be lowercase
type attribute
There is no need to specify type attributes for CSS and JS, they are included by default in HTML5
*recommend:*
<link rel="stylesheet" href="" >
<script src=""></script>
*Not recommended:*
<link rel="stylesheet" type="text/css" href="" >
<script type="text/javascript" src="" ></script>
element properties
Element attribute values use double quote syntax
Write all the element attribute values that can be written on
Special character references
The special characters "<" and ">" cannot be used in HTML. The browser will parse them as tags. To display them correctly, use character entities in the HTML source code.
*recommend:*
<a href="#">more>></a>
*Not recommended:*
<a href="#">more>></a>
Code indentation
Uniformly use four spaces for code indentation so that all editors behave consistently (each editor has relevant configurations)
code nesting
Element nesting specifications, each block element is on its own line, inline elements are optional
*recommend:*
<div> <h1></h1> <p></p> </div> <p><span></span><span></span></p>
*Not recommended:*
<div> <h1></h1><p></p> </div> <p> <span></span> <span></span> </p>
Paragraph elements and title elements can only nest inline elements
*recommend:*
<h1><span></span></h1> <p><span></span><span></span></p>
*Not recommended:*
<h1><div></div></h1> <p><div></div><div></div></p>
Picture specifications
Content map
Content images mostly exist in the form of photo images such as product images, with rich colors and large file sizes.
JPEG format will be given priority, and WebP format will be given priority if conditions permit.
Try not to use PNG format, PNG8 has too low color bits, PNG24 has low compression rate and large file size.
The size of a single image on the PC platform should not be larger than 200KB.
Background image
Background images are mostly icons and other pictures with relatively simple colors, small file sizes, and decorative effects.
PNG and GIF formats, give priority to using PNG format, PNG format allows more colors and provides better compression rate
For images with relatively simple colors, such as solid color block line icons, give priority to using the PNG8 format and avoid using the JPEG format.
The PNG24 format will be preferred if the image is rich in color and the image file is not too large (less than 40KB) or has a translucent effect.
For images with rich colors and relatively large files (40KB - 200KB), JPEG format is preferred
Wherever possible, WebP will be preferred over PNG and JPEG formats.
css specification
Code formatting
style writing
Compact format (Compact)
.jdc{ display: block;width: 50px;}
Expanded format (Expanded)
.jdc { display: block; width: 50px; }
Code case
Style selectors, attribute names, and attribute value keywords are all written in lowercase letters, and uppercase and lowercase letters are allowed in attribute strings.
Selector
Use the universal selector `*` sparingly - Don't use ID selector - Do not use tag selectors without specific semantic definitions
*recommend:*
.jdc{} .jdcli{} .jdc li p{}
*Not recommended:*
*{} #jdc {} .jdc div{}
Code indentation
Uniformly use four spaces for code indentation so that all editors behave consistently (each editor has relevant configurations)
semicolon
A semicolon must be added at the end of each attribute declaration;
Code readability
There is a space between the opening bracket and the class name, and a space between the colon and the attribute value.
Comma separated values, a space after the comma
Open a new line for a single css selector or new declaration
There are no spaces in the color values `rgb()` `rgba()` `hsl()` `hsla()` `rect()`, and the values should not contain unnecessary 0s
*recommend:*
.jdc { color: rgba(255,255,255,.5);
*Not recommended:*
.jdc { color: rgba(255, 255, 255, 0.5); }
If the hexadecimal value of the attribute value can be abbreviated, use abbreviations as much as possible.
*recommend:*
.jdc { color: #fff; }
*Not recommended:*
.jdc { color: #ffffff; }
Do not specify units for `0`
*recommend:*
.jdc { margin: 0 10px; }
*Not recommended:*
.jdc { margin: 0px 10px; }
attribute value quotes
When css attribute values require quotation marks, use single quotation marks uniformly.
Attribute writing order
1. Layout positioning attributes: display / position / float / clear / visibility / overflow (it is recommended to write display first, after all, it is related to the mode)
2. Own properties: width / height / margin / padding / border / background
3. Text attributes: color/font/text-decoration/text-align/vertical-align/white-space/break-word
4. Other properties (CSS3): content/cursor/border-radius/box-shadow/text-shadow/background:linear-gradient…
Naming conventions
Directory naming
* Project folder: shopping
* Style folder: css
* Script folder: js
* Style picture folder: img
* Product picture folder: upload
* Font folder: fonts
ClassName naming
The name of ClassName should be as short and clear as possible. The name must start with a **letter**, and **all letters are lowercase**, and **underscores** should be used between words** "_" to connect
Commonly used naming recommendations
**Notice**
It is not recommended to directly use ad, banner, gg, guanggao, etc. that may be linked to advertising, because some browser plug-ins (Chrome ad blocking plug-ins, etc.) will directly filter these class names, so <div class="ad"></div>The English or Pinyin name of this kind of advertisement should not appear In addition, **sensitive and disharmonious words** should not appear