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 codes feel very good. Reprint it and share it with you:
ps: Original address: http://css-tricks.com/what-beautiful-html-code-looks-like/
1.DOCTYPE Properly DeclaredDon't forget the declaration at the head, it will tell the browser how to render your HTML.
2.Tidy Head SectionSet the title, character set. Configure CSS and JS external links (including a print CSS).
3.Body IDed Give body an ID. The reason the author mentioned here is to facilitate the selection of medium containers for 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 structure before using it. 4.Semantically Clean MenuWrite menu code that matches semantics.
<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: I personally think it should be easier to write code like this:
<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 is a body DIV that contains all the contents. Convenient to fix the width, margins, etc. of the body. 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 at the end. 7.Common Content INCLUDED Introduce common parts such as navigation and end of pages through dynamic calls, such as PHP include. 8.Code is Tabbed into Sections Indent code 9.Proper Ending Tags Note the end tag 10.Hierarchy of Header Tags Use title tags such as <h1>~<h6> where appropriate to divide paragraphs. 11. Content, Content, Contentuses appropriate tags and logo codes, and use &
copy; to indicate ©, do not use</br> 12.No Styling! Don't write styles on tags, HTML is just used to represent structures. Let's leave the performance to CSS.