Home >Web Front-end >HTML Tutorial >HTML project code writing specifications_html/css_WEB-ITnose
If there are any errors or violations in this document, please correct them.
No matter how many people work on the same project, make sure every line of code looks like it was written by the same person.
If you do not understand anything in this document, or feel it is inconsistent with the regulations, please send me an email in the following format. Anyone is welcome to participate in the discussion and jointly improve this document. Many of the contents in this document are also based on my own current company needs.
Email is not QQ. Please organize your language as clearly as possible and describe the problem more clearly. At the same time, do not use too much styling and comply with document formatting standards. Thank you.
Front-end projects uniformly manage project files according to the following directory structure:
/path/to/PROJECT_NAME/ scss/ base.scss main.scss _module_name.scss scripts/ build.js gulp.js build/ vendor/ THIRD_PARTY_LIBRARY_NAME/ VERSION/ MINIFIED_FILE_NAME/ assets/ css/ base.min.css base.min.map main.min.css main.min.map img/ logo.png logo@2x.png logo@3x.png js/ main.min.js main.min.map index.html layout.html PAGE_NAME.html template/ vendor/ THIRD_PARTY_LIBRARY_NAME/ VERSION/ MINIFIED_FILE_NAME/ assets/ css/ base.css main.css img/ logo.png js/ main.js index.html layout.html PAGE_NAME.html
Above In the directory structure, the uppercase names are variable, that is, they can be changed at any time according to specific needs. Their semantics are:
PROJECT_NAME
The English name of the current project (if Dingdang Wallet official cannot provide a standard translation, or Pinyin is its name, the full Pinyin name will be used, or its officially defined short name will be used), consisting of pure lowercase letters a-z or numbers 0-9 and underscore - a string composed of
template
template directory, used for development
build
Build directory
vendor
All third-party files are stored in In the vendor directory, any third-party libraries, styles, scripts, etc. need to be stored according to the following rules: any third-party library needs to be stored under its name. During the development process, use bower to install it.
Any HTML page must use the following document type declaration:
<!DOCTYPE html>
No statements other than this statement are allowed to appear in the HTML interface of any project in Dingdong Wallet.
Use HTML legally and use w3c tool (W3C HTML validator) to check.
Use HTML tags reasonably according to the purpose, such as header, footer, nav, section and other tags. They are very similar to div, but they are very different in semantics, such as the following :
<article class="entry"> <header> <h1>读《双城记》</h1> </header> <section class="content"> <p><strong>《双城记》</strong>(英语:<em>A Tale of Two Cities</em>)是英国作家查尔斯·狄更斯所著的一部以法?大革命为背景所写成的长篇历史小说,情?感人肺腑,是世界文??典名著之一,故事中?巴黎、?敦??大城市??起?,围绕着曼奈特医生一家和以德法奇夫妇为首的圣安东尼区展开故事。小说里描写了贵族如何败坏、如何残害百姓,人民心中积压对贵族的刻骨仇恨,导致了不可避免的法国大革命。本书的主要思想是为了爱而自我牺牲,?名中的「?城」指的是<strong>巴黎??敦</strong>。</p> <h2>人物介?</h2> <ul> <li>曼奈特?生(Dr. Alexandre Manette),一位老政治犯。</li> <li>露西·曼奈特(Lucie Manette),曼奈特?生的女?。</li> <li>查?斯·丹尼(Charles Darney),厄弗?蒙地侯爵的?子,?上露西·曼奈特。</li> <li>雪尼?卡?(Sydney Carton),一位?世嫉俗的律?,?上露西·曼奈特。</li> <li>德法奇(Ernest Defarge),曼奈特?生?日的?人。</li> <li>德法奇夫人(Madame Defarge/Teresa Defarge),一位?定的女革命者。</li> <li>?翰·拔沙(John Barsad),一位??。他的真?名字是索??(Solomon Pross) ,是波希小姐(Miss Pross)的哥哥。</li> <li>波希小姐(Miss Pross),露西的保姆。</li> <li>??·?利(Roger Cly),另一位??,?翰·拔沙的夥伴</li> </ul> </section></article><!-- /.entry -->
It is recommended to omit the http: and https: protocol parts in URL addresses pointing to images, style sheets, JavaScript scripts or other media files, unless the corresponding file is known It is not compatible with both protocols at the same time, for example:
We do not recommend the following method:
<script src="http://www.doraemoney.com/vendor/jquery/2.1.3/jquery.min.js"></script><link rel="stylesheet" href="http://assets/css/style.css"/><style> .example { background: #fff url(http://www.doraemoney.com/assets/img/example-background.png) no-repeat center; }</style>
You should write like the following:
<script src="//www.doraemoney.com/vendor/jquery/2.1.3/jquery.min.js"></script><link rel="stylesheet" href="//assets/css/style.css"/><style> .example { background: #fff url(//www.doraemoney.com/assets/img/example-background.png) no-repeat center; }</style>
In addition Examples, such as introducing images through the a1f02c36ba31691bcfe87b2722de723b tag, we do not recommend writing like this:
<img src="http://www.doraemoney.com/assets/img/logo.png" alt="叮当钱包" class="logo"/>
but should write like this:
<img src="//www.doraemoney.com/assets/img/logo.png" alt="叮当钱包" class="logo"/>
Tab is not allowed to be used for indentation in any HTML, CSS and JavaScript code, and all indentations are only allowed to use two spaces__, as follows is correct:
<a class="brand"> <img src="//www.doraemoney.com/assets/img/logo.png" alt="叮当钱包" /></a>
And The following are incorrect:
<a class="brand"> <img src="//www.doraemoney.com/assets/img/logo.png" alt="叮当钱包" /></a>
All code should be in lowercase, including element names, attributes, and attribute values (unless text or CDATA content), Selectors, CSS attributes and attribute values are all wrong as follows:
<A HREF="http://www.doraemoney.com" TITLE="叮当钱包官方网站首页" CLASS="Brand"/>叮当钱包</A>
The correct writing should be:
<a href="http://www.doraemoney.com" title="叮当钱包官方网站首页" class="brand">叮当钱包</a>
We also require the naming of resource files. All use pure lowercase letters. At the same time, multiple words are separated by a horizontal line (-). At the same time, spaces are not allowed to appear in the name. English letters must be placed in the first position. - is not allowed to appear in the name format with a decimal point suffix. In front of ., the following is the correct naming method:
logo.pngexample-background.pngassets/css/base.css
The following are incorrect:
logo-.png-logo.png0logo.pngexample background.pngExample-Background.pngExampleBackground.pngAssets/Css/Base.css
Trailing spaces are Absolutely not allowed, it will easily make the diff more complicated. For example, the following is not allowed:
<h2>什么是叮当钱包? </h2><p>叮当钱包的命名灵感来源于哆啦A梦的四次元口袋,叮当希望自己也可以像这个神奇口袋一样,在小伙伴需要帮助时,伸出温暖援(圆)手,给予大家“无所不能”的帮助。</p>
The following is correct:
<h2>什么是叮当钱包?</h2><p>叮当钱包的命名灵感来源于哆啦A梦的四次元口袋,叮当希望自己也可以像这个神奇口袋一样,在小伙伴需要帮助时,伸出温暖援(圆)手,给予大家“无所不能”的帮助。</p>
Pay attention to careful observation, in h2 In tag? Are there any spaces after the number?
All files, including .html, .css, .js, scss, less, etc., must all use utf-8 encoding format. The following is correct:
<head> <meta charset="utf-8" /></head>
Anyone who writes code must write code comments as needed. This is very important for team development. For example, the following is the HTML comment specification:
<!-- 这是单行注释 --><div class="foo"></bar><!-- 这是多行注释的标题 这是多行注释中的一行-->