This project is used to record specifications and high-level Maintainable front-end code, this is a front-end code writing specification summarized by analyzing many front-end code libraries on Github.
Directory
Front-end universal specification
HTML specification
CSS specification
JS specification
License
public domain, Just take it.
Thanks
@Ruan YiFeng:
@materliu:https://materliu.github.io/code-guide
@hzlzh:
@tguide:
Front-end Universal Standards
Golden Rules
Always follow the same set of coding standards, which can be listed here or summarized by yourself. If you find any errors in this specification, 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.
Project naming
Project names are all lowercase and separated by dashes. Camel case naming is prohibited. For example: my-project-name
File naming
File naming refers to the previous rule. When it consists of multiple words, use the dash connection method, for example: error-report.html
When there is a plural structure, plural naming should be used, for example: scripts, styles, images, data-models
The file name can only contain lowercase English letters a~z and sorting numbers 0~ 9 or separator -, it is prohibited to include special symbols, such as spaces, $, etc.
To better express semantics, the file name uses English nouns, or English abbreviations.
It is not allowed to name English words with advertisements, such as ad, adv, adver, advertising, to prevent this module from being filtered out by the browser as a spam advertisement. This is true for any file naming.
index.shtml Guide page&Homepage
main.shtml Homepage
download.shtml Download page
act.html Activity list page
video.html Video
cdkey. html CDKEY page
base.css basic style
layout.css frame layout
##module .css module style
global.css global style
font.css font style
index.css Home page style
link.css Link style
print.css Print style
HTML SpecificationSyntaxUse four spaces for indentation. This is the only way to ensure that the code displays consistently in various environments. Nested nodes should be indented (four spaces). On attributes, use double quotes, not single quotes. Don't use slashes at the end of auto-closing tags - the HTML5 specification states that they are optional. Don't ignore optional closing tags (for example, and
).

Copy after login
HTML5 doctype
Use this simple doctype at the beginning of every HTML page to enable standards mode so that it displays as consistently as possible in every browser.
Although doctype is not case-sensitive, by convention, doctype is capitalized
<!DOCTYPE html>
Copy after login
Language attributes
<html lang="en"></html>
Copy after login
Character encoding
By explicitly declaring the character encoding, you can Ensure that the browser can quickly and easily determine how the page content should be rendered. The
advantage of doing this is that you can avoid using character entity tags in HTML, so that they are all consistent with the document encoding (generally using UTF-8 encoding).
<meta charset="UTF-8">
Copy after login
IE Compatibility Mode
IE supports specific tags to determine the IE version that should be used to draw the current page. Unless there are strong special needs, it is best to set it to edge mode to notify IE to adopt the latest mode it supports.
According to the HTML5 specification, there is usually no need to specify type when introducing CSS and JavaScript, because text/css and text/javascript are their default values respectively.
Try to follow HTML standards and semantics, but it should not be at the expense of wasting practicality. At all times, problems must be solved with as little complexity and as few labels as possible.
Reduce the number of tags
When writing HTML code, you need to try to avoid redundant parent nodes. Many times, it takes iteration and refactoring to make the HTML less. Consider the following example:
<!-- Not so great --><span class="avatar">
</span><!-- Better -->

Copy after login
Attribute order
HTML attributes should appear in a specific order to ensure readability.
class
id
##name
data-*
src, for, type, href, value, max-length, max, min, pattern
placeholder, title , alt
aria-*, role
required, readonly, disabled
##class yes Designed for highly reusable components, they should theoretically come first. ids are more specific and should be used sparingly (for example, in-page bookmarks), so they come second. Boolean attribute
Boolean attribute refers to an attribute that does not need to declare a value. XHTML requires a declared value for each attribute, but HTML5 does not.
function doSomething(item) {// do something
}var doSomething = function (item) {// do something
}// Good
doSomething(item);// Bad: Looks like a block statement
doSomething (item);// Good
(function() { "use strict";function doSomething() {// code
}
})();
Copy after login
The above is the detailed content of Web front-end code specifications. For more information, please follow other related articles on the PHP Chinese website!
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
What to do with blue screen code 0x0000001? The blue screen error is a warning mechanism when there is a problem with the computer system or hardware. Code 0x0000001 usually indicates a hardware or driver failure. When users suddenly encounter a blue screen error while using their computer, they may feel panicked and at a loss. Fortunately, most blue screen errors can be troubleshooted and dealt with with a few simple steps. This article will introduce readers to some methods to solve the blue screen error code 0x0000001. First, when encountering a blue screen error, we can try to restart
If you need to program any device remotely, this article will help you. We will share the top GE universal remote codes for programming any device. What is a GE remote control? GEUniversalRemote is a remote control that can be used to control multiple devices such as smart TVs, LG, Vizio, Sony, Blu-ray, DVD, DVR, Roku, AppleTV, streaming media players and more. GEUniversal remote controls come in various models with different features and functions. GEUniversalRemote can control up to four devices. Top Universal Remote Codes to Program on Any Device GE remotes come with a set of codes that allow them to work with different devices. you may
As a programmer, I get excited about tools that simplify the coding experience. With the help of artificial intelligence tools, we can generate demo code and make necessary modifications as per the requirement. The newly introduced Copilot tool in Visual Studio Code allows us to create AI-generated code with natural language chat interactions. By explaining functionality, we can better understand the meaning of existing code. How to use Copilot to generate code? To get started, we first need to get the latest PowerPlatformTools extension. To achieve this, you need to go to the extension page, search for "PowerPlatformTool" and click the Install button
PHP and Vue: a perfect pairing of front-end development tools. In today's era of rapid development of the Internet, front-end development has become increasingly important. As users have higher and higher requirements for the experience of websites and applications, front-end developers need to use more efficient and flexible tools to create responsive and interactive interfaces. As two important technologies in the field of front-end development, PHP and Vue.js can be regarded as perfect tools when paired together. This article will explore the combination of PHP and Vue, as well as detailed code examples to help readers better understand and apply these two
Working with files in the Linux operating system requires the use of various commands and techniques that enable developers to efficiently create and execute files, code, programs, scripts, and other things. In the Linux environment, files with the extension ".a" have great importance as static libraries. These libraries play an important role in software development, allowing developers to efficiently manage and share common functionality across multiple programs. For effective software development in a Linux environment, it is crucial to understand how to create and run ".a" files. This article will introduce how to comprehensively install and configure the Linux ".a" file. Let's explore the definition, purpose, structure, and methods of creating and executing the Linux ".a" file. What is L
Cockpit is a web-based graphical interface for Linux servers. It is mainly intended to make managing Linux servers easier for new/expert users. In this article, we will discuss Cockpit access modes and how to switch administrative access to Cockpit from CockpitWebUI. Content Topics: Cockpit Entry Modes Finding the Current Cockpit Access Mode Enable Administrative Access for Cockpit from CockpitWebUI Disabling Administrative Access for Cockpit from CockpitWebUI Conclusion Cockpit Entry Modes The cockpit has two access modes: Restricted Access: This is the default for the cockpit access mode. In this access mode you cannot access the web user from the cockpit
In front-end development interviews, common questions cover a wide range of topics, including HTML/CSS basics, JavaScript basics, frameworks and libraries, project experience, algorithms and data structures, performance optimization, cross-domain requests, front-end engineering, design patterns, and new technologies and trends. . Interviewer questions are designed to assess the candidate's technical skills, project experience, and understanding of industry trends. Therefore, candidates should be fully prepared in these areas to demonstrate their abilities and expertise.
Since the launch of ChatGLM-6B on March 14, 2023, the GLM series models have received widespread attention and recognition. Especially after ChatGLM3-6B was open sourced, developers are full of expectations for the fourth-generation model launched by Zhipu AI. This expectation has finally been fully satisfied with the release of GLM-4-9B. The birth of GLM-4-9B In order to give small models (10B and below) more powerful capabilities, the GLM technical team launched this new fourth-generation GLM series open source model: GLM-4-9B after nearly half a year of exploration. This model greatly compresses the model size while ensuring accuracy, and has faster inference speed and higher efficiency. The GLM technical team’s exploration has not