Beautiful code is the foundation of a beautiful website. Excellent CSS only exists on top of equally excellent HTML. Clean, semantic HTML code makes a website more robust. This article describes 12 laws for achieving clean web design code, suitable for anyone engaged in web design. 1. Strict DOCTYPE
![]() References:
![]() References:
![]() 5. Correctly nest tag tags as shown below, in the first line of code, the <h1> tag is nested in the <a> tag. Although most browsers will render it correctly, this is not a good habit. The tag is a block object, but an inline object, and an inline object should not contain a block object. ![]() 6. Eliminate unnecessary <div> <div> is often abused (especially in the DIV+CSS myth we are in now - translator), people want to put everything in a <div> in order to assign CSS styles to them, this abuse will lead to bloat. ![]() References:
![]() 8. Try to use CSS to control the layout of text as shown in the figure below. Do not use uppercase directly. Use CSS to control the format of these text layouts, which will be more flexible. ![]() 9. Assign a separate class/id to <body> Assigning a separate class/id to the body tag is a good way to locate any object in the page, because all objects in the page are located in the body. ![]() References:
There is no need to be too rigid about whether a website passes W3C validation or not. There are many more considerations in Web design. If you only stick to the W3C validation results, it may affect some more important factors. For example, IE6 has many bugs in W3C standards. If you announce that your website does not support IE6 in order to pass W3C validation 100%, it will be more trouble than gain, at least in China. - Translator ![]() References:
![]() 12. Do your best If you are writing from scratch, it is certainly much easier to stick to the above principles. If you have to modify old code, it will be painful. Some CMS systems have poor coding that will bog you down, or your website is large and there are too many things to change. In any case, it is very important to always maintain good habits. ![]() |
<<: Detailed process of installing Docker, creating images, loading and running NodeJS programs
>>: How to use javascript to do simple algorithms
background PNG images take up more storage space ...
Preface When writing front-end pages, we often us...
Part of the code: Copy code The code is as follow...
This article example shares the specific code of ...
How to set up a MySQL short link 1. Check the mys...
Environmental preparation: Deploy lnmp on a host ...
This article shares the specific code for JavaScr...
1. MySQL gets the current date and time function ...
Configure multiple servers in nginx.conf: When pr...
Common usage of Regexp in Mysql Fuzzy matching, c...
Problem description (what is keep-alive) keep-ali...
Three ways to define functions in JS Let me expla...
I installed a virtual machine a long time ago, an...
Table of contents background 1. Document Descript...
What you learn from books is always shallow, and ...