HTML project code writing specifications_html/css_WEB-ITnose
Jun 24, 2016 am 11:45 AM
If there are any errors or violations in this document, please correct them.
Introduction
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.
Project file structure
Front-end project file structure
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.
HTML Standard Description
Document Type
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.
Legality Verification
Use HTML legally and use w3c tool (W3C HTML validator) to check.
Semantic
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>(英語(yǔ):<em>A Tale of Two Cities</em>)是英國(guó)作家查爾斯·狄更斯所著的一部以法?大革命為背景所寫(xiě)成的長(zhǎng)篇?dú)v史小說(shuō),情?感人肺腑,是世界文??典名著之一,故事中?巴黎、?敦??大城市??起?,圍繞著曼奈特醫(yī)生一家和以德法奇夫婦為首的圣安東尼區(qū)展開(kāi)故事。小說(shuō)里描寫(xiě)了貴族如何敗壞、如何殘害百姓,人民心中積壓對(duì)貴族的刻骨仇恨,導(dǎo)致了不可避免的法國(guó)大革命。本書(shū)的主要思想是為了愛(ài)而自我犧牲,?名中的「?城」指的是<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 -->
Protocol header
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 tag, we do not recommend writing like this:
<img src="http://www.doraemoney.com/assets/img/logo.png" alt="叮當(dāng)錢包" class="logo"/>
but should write like this:
<img src="//www.doraemoney.com/assets/img/logo.png" alt="叮當(dāng)錢包" class="logo"/>
Code indentation
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="叮當(dāng)錢包" /></a>
And The following are incorrect:
<a class="brand"> <img src="//www.doraemoney.com/assets/img/logo.png" alt="叮當(dāng)錢包" /></a>
Case
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="叮當(dāng)錢包官方網(wǎng)站首頁(yè)" CLASS="Brand"/>叮當(dāng)錢包</A>
The correct writing should be:
<a href="http://www.doraemoney.com" title="叮當(dāng)錢包官方網(wǎng)站首頁(yè)" class="brand">叮當(dāng)錢包</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
Trailing spaces are Absolutely not allowed, it will easily make the diff more complicated. For example, the following is not allowed:
<h2>什么是叮當(dāng)錢包? </h2><p>叮當(dāng)錢包的命名靈感來(lái)源于哆啦A夢(mèng)的四次元口袋,叮當(dāng)希望自己也可以像這個(gè)神奇口袋一樣,在小伙伴需要幫助時(shí),伸出溫暖援(圓)手,給予大家“無(wú)所不能”的幫助。</p>
The following is correct:
<h2>什么是叮當(dāng)錢包?</h2><p>叮當(dāng)錢包的命名靈感來(lái)源于哆啦A夢(mèng)的四次元口袋,叮當(dāng)希望自己也可以像這個(gè)神奇口袋一樣,在小伙伴需要幫助時(shí),伸出溫暖援(圓)手,給予大家“無(wú)所不能”的幫助。</p>
Pay attention to careful observation, in h2 In tag? Are there any spaces after the number?
Encoding format
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>
Code Comments
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><!-- 這是多行注釋的標(biāo)題 這是多行注釋中的一行-->

Hot AI Tools

Undress AI Tool
Undress images for free

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

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

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

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

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

ARIA's role attribute is used to define the role of web elements and improve accessibility. 1. Role attribute helps assistive technology to understand the functions of elements, such as buttons, navigation, etc. 2. Use role attributes to assign specific roles to non-semantic HTML elements. 3. The role attribute should be consistent with the element behavior and be verified by the accessibility tool test.

How to create a website layout? 1. Use HTML tags to define the content structure, such as, ,. 2. Control styles and positions through CSS, using box model, float or Flexbox layout. 3. Optimize performance, reduce HTTP requests, use cache and optimize images, and ensure responsive design.

Improve the readability and maintainability of HTML code can be achieved through the following steps: 1. Use semantic tags, such as, etc. to make the code structure clear and improve SEO effect; 2. Keep the code formatted and use consistent indentation and spaces; 3. Add appropriate comments to explain the code intention; 4. Avoid excessive nesting and simplify the structure; 5. Use external style sheets and scripts to keep the HTML concise.

The key to keep up with HTML standards and best practices is to do it intentionally rather than follow it blindly. First, follow the summary or update logs of official sources such as WHATWG and W3C, understand new tags (such as) and attributes, and use them as references to solve difficult problems; second, subscribe to trusted web development newsletters and blogs, spend 10-15 minutes a week to browse updates, focus on actual use cases rather than just collecting articles; second, use developer tools and linters such as HTMLHint to optimize the code structure through instant feedback; finally, interact with the developer community, share experiences and learn other people's practical skills, so as to continuously improve HTML skills.

The reason for using tags is to improve the semantic structure and accessibility of web pages, make it easier for screen readers and search engines to understand page content, and allow users to quickly jump to core content. Here are the key points: 1. Each page should contain only one element; 2. It should not include content that is repeated across pages (such as sidebars or footers); 3. It can be used in conjunction with ARIA properties to enhance accessibility. Usually located after and before, it is used to wrap unique page content, such as articles, forms or product details, and should be avoided in, or in; to improve accessibility, aria-labeledby or aria-label can be used to clearly identify parts.

To create a basic HTML document, you first need to understand its basic structure and write code in a standard format. 1. Use the declaration document type at the beginning; 2. Use the tag to wrap the entire content; 3. Include and two main parts in it, which are used to store metadata such as titles, style sheet links, etc., and include user-visible content such as titles, paragraphs, pictures and links; 4. Save the file in .html format and open the viewing effect in the browser; 5. Then you can gradually add more elements to enrich the page content. Follow these steps to quickly build a basic web page.

To create an HTML checkbox, use the type attribute to set the element of the checkbox. 1. The basic structure includes id, name and label tags to ensure that clicking text can switch options; 2. Multiple related check boxes should use the same name but different values, and wrap them with fieldset to improve accessibility; 3. Hide native controls when customizing styles and use CSS to design alternative elements while maintaining the complete functions; 4. Ensure availability, pair labels, support keyboard navigation, and avoid relying on only visual prompts. The above steps can help developers correctly implement checkbox components that have both functional and aesthetics.

HTMLtagsareessentialforstructuringwebpages.Theydefinecontentandlayoutusinganglebrackets,ofteninpairslikeand,withsomebeingself-closinglike.HTMLtagsarecrucialforcreatingstructured,accessible,andSEO-friendlywebpages.
