How to write beautiful HTML code

How to write beautiful HTML code

What Beautiful HTML Code Looks Like How to write beautiful HTML code.
An article written by a foreigner: What Beautiful HTML Code Looks Like How to write beautiful HTML code feels very well written, so I reposted it and shared it with you:
ps: Original address: http://css-tricks.com/what-beautiful-html-code-looks-like/
1. DOCTYPE Properly Declared
Don't forget the header declaration, which tells the browser how to render your HTML.
2. Tidy Head Section
Set the title and character set. Link the CSS and JS to external links (including a CSS for printing).
3.Body IDed
Give the body an ID. The reason mentioned by the author here is to facilitate the selection of containers in multiple pages. For example, by setting different IDs for BODY in page1 and page2, you can set two different effects through #page1 h2 and #page2 h2. I feel that this depends on the situation and the specific architecture.
4.Semantically Clean Menu
Write semantic menu code.
<div id="menu">
<ul>
<li><a href="index.php">Home</a></li>
<li><a href="about.php">About</a></li>
<li><a href="contact.php">Contact</a></li>
</ul>
</div>
ps:我個人覺得這樣寫代碼應該更簡單一點吧:
<ulid="menu">
<li><a href="index.php">Home</a></li>
<li><a href="about.php">About</a></li>
<li><a href="contact.php">Contact</a></li>
</ul>

5.Main DIV for all Page Content
There should be a main DIV that contains all the content. It is convenient to fix the width, margins, etc. of the subject.
6. Important Content First
Write the main content first, then the secondary content. If your navigation or sidebar is not very important, it is best to write them last.
7. Common Content Included
Import common parts such as navigation and footer through dynamic calls, such as PHP include.
8.Code is Tabbed into Sections
Indent code
9.Proper Ending Tags
Note the closing tag
10.Hierarchy of Header Tags
Use heading tags, such as <h1>~<h6>, to divide paragraphs where appropriate.
11. Content, Content, Content
Use appropriate labels and sign codes, use &
copy; to indicate ©, and do not use </br>
12.No Styling!
Don't put styles in tags; HTML is only used to represent structure. Let CSS handle the performance.

<<:  Quickly get started with VUE 3 teleport components and usage syntax

>>:  How to implement dynamic automatic up and down of upstream servers without reload based on nginx

Recommend

Docker container log analysis

View container logs First, use docker run -it --r...

Implementation of mysql data type conversion

1. Problem There is a table as shown below, we ne...

Introduction to the functions and usage of value and name attributes in Html

1. The value used in the button refers to the text...

Detailed installation and use of virtuoso database under Linux system

I've been researching some things about linke...

TypeScript Enumeration Type

Table of contents 1. Overview 2. Digital Enumerat...

js array entries() Get iteration method

Table of contents 1. Detailed syntax of entires()...

HTML&CSS&JS compatibility tree (IE, Firefox, Chrome)

What is a tree in web design? Simply put, clicking...

A brief analysis of whether using iframe to call a page will cache the page

Recently, I have a project that requires using ifr...

How to implement remote automatic backup of MongoDB in Linux

Preface After reading the previous article about ...

Nginx installation detailed tutorial

1. Brief Introduction of Nginx Nginx is a free, o...

Detailed explanation of how Vue components transfer values ​​to each other

Table of contents Overview 1. Parent component pa...

Detailed explanation of JS browser event model

Table of contents What is an event A Simple Examp...