Table of Contents
Introduction
Project file structure
Front-end project file structure
HTML Standard Description
Document Type
Legality Verification
Semantic
Protocol header
Code indentation
Case
Trailing spaces
Encoding format
Code Comments
Home Web Front-end HTML Tutorial HTML project code writing specifications_html/css_WEB-ITnose

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
Copy after login

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>
Copy after login

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>(英语:<em>A Tale of Two Cities</em>)是英国作家查尔斯&middot;狄更斯所著的一部以法?大革命为背景所写成的长篇历史小说,情?感人肺腑,是世界文??典名著之一,故事中?巴黎、?敦??大城市??起?,围绕着曼奈特医生一家和以德法奇夫妇为首的圣安东尼区展开故事。小说里描写了贵族如何败坏、如何残害百姓,人民心中积压对贵族的刻骨仇恨,导致了不可避免的法国大革命。本书的主要思想是为了爱而自我牺牲,?名中的「?城」指的是<strong>巴黎??敦</strong>。</p>    <h2>人物介?</h2>    <ul>      <li>曼奈特?生(Dr. Alexandre Manette),一位老政治犯。</li>      <li>露西&middot;曼奈特(Lucie Manette),曼奈特?生的女?。</li>      <li>查?斯&middot;丹尼(Charles Darney),厄弗?蒙地侯爵的?子,?上露西&middot;曼奈特。</li>      <li>雪尼?卡?(Sydney Carton),一位?世嫉俗的律?,?上露西&middot;曼奈特。</li>      <li>德法奇(Ernest Defarge),曼奈特?生?日的?人。</li>      <li>德法奇夫人(Madame Defarge/Teresa Defarge),一位?定的女革命者。</li>      <li>?翰&middot;拔沙(John Barsad),一位??。他的真?名字是索??(Solomon Pross) ,是波希小姐(Miss Pross)的哥哥。</li>      <li>波希小姐(Miss Pross),露西的保姆。</li>      <li>??&middot;?利(Roger Cly),另一位??,?翰&middot;拔沙的夥伴</li>    </ul>  </section></article><!-- /.entry -->
Copy after login

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>
Copy after login

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>
Copy after login

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="叮当钱包" class="logo"/>
Copy after login

but should write like this:

<img src="//www.doraemoney.com/assets/img/logo.png" alt="叮当钱包" class="logo"/>
Copy after login

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="叮当钱包" /></a>
Copy after login

And The following are incorrect:

<a class="brand">    <img src="//www.doraemoney.com/assets/img/logo.png" alt="叮当钱包" /></a>
Copy after login

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="叮当钱包官方网站首页" CLASS="Brand"/>叮当钱包</A>
Copy after login

The correct writing should be:

<a href="http://www.doraemoney.com" title="叮当钱包官方网站首页" class="brand">叮当钱包</a>
Copy after login

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
Copy after login

The following are incorrect:

logo-.png-logo.png0logo.pngexample background.pngExample-Background.pngExampleBackground.pngAssets/Css/Base.css
Copy after login

Trailing spaces

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>
Copy after login

The following is correct:

<h2>什么是叮当钱包?</h2><p>叮当钱包的命名灵感来源于哆啦A梦的四次元口袋,叮当希望自己也可以像这个神奇口袋一样,在小伙伴需要帮助时,伸出温暖援(圆)手,给予大家“无所不能”的帮助。</p>
Copy after login

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>
Copy after login

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><!--  这是多行注释的标题  这是多行注释中的一行-->
Copy after login
Statement of this Website
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

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 Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

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 &lt;progress&gt; element, its purpose, styling, and differences from the &lt;meter&gt; element. The main focus is on using &lt;progress&gt; for task completion and &lt;meter&gt; for stati

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 &lt;datalist&gt; element, which enhances forms by providing autocomplete suggestions, improving user experience and reducing errors.Character count: 159

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 &lt;meter&gt; element, used for displaying scalar or fractional values within a range, and its common applications in web development. It differentiates &lt;meter&gt; from &lt;progress&gt; and ex

Is HTML easy to learn for beginners? Is HTML easy to learn for beginners? Apr 07, 2025 am 12:11 AM

HTML is suitable for beginners because it is simple and easy to learn and can quickly see results. 1) The learning curve of HTML is smooth and easy to get started. 2) Just master the basic tags to start creating web pages. 3) High flexibility and can be used in combination with CSS and JavaScript. 4) Rich learning resources and modern tools support the learning process.

What is the viewport meta tag? Why is it important for responsive design? What is the viewport meta tag? Why is it important for responsive design? Mar 20, 2025 pm 05:56 PM

The article discusses the viewport meta tag, essential for responsive web design on mobile devices. It explains how proper use ensures optimal content scaling and user interaction, while misuse can lead to design and accessibility issues.

What is the purpose of the <iframe> tag? What are the security considerations when using it? What is the purpose of the <iframe> tag? What are the security considerations when using it? Mar 20, 2025 pm 06:05 PM

The article discusses the &lt;iframe&gt; tag's purpose in embedding external content into webpages, its common uses, security risks, and alternatives like object tags and APIs.

The Roles of HTML, CSS, and JavaScript: Core Responsibilities The Roles of HTML, CSS, and JavaScript: Core Responsibilities Apr 08, 2025 pm 07:05 PM

HTML defines the web structure, CSS is responsible for style and layout, and JavaScript gives dynamic interaction. The three perform their duties in web development and jointly build a colorful website.

What is an example of a starting tag in HTML? What is an example of a starting tag in HTML? Apr 06, 2025 am 12:04 AM

AnexampleofastartingtaginHTMLis,whichbeginsaparagraph.StartingtagsareessentialinHTMLastheyinitiateelements,definetheirtypes,andarecrucialforstructuringwebpagesandconstructingtheDOM.

See all articles