5 common html errors during website construction
1. Settings of web page background color
Chance of mistake: Very high
Universality: wider
Possibility of making mistakes: lazy/not sure
About 2 years ago, I discovered that there was no background color on 21cn. I notified them using email, and I have never made this problem since then.
Most people have white background colors in windows, but if someone like me is a person, they will change the background color of the windows windows to gray or other colors. In this way, if you do not set the background color of the web page, you think a normal web page will look like a mess on my computer.
2. Abuse of align center
The probability of making a mistake: very high
Universality: Very wide
Possibility of making mistakes: think it is convenient / think it is easy to use
At work, it is common to modify and maintain other people's web pages, and I found that many people have a bad habit:
In the text or picture in the table, how do you make it center, left or right?
〈div align=center>Hello everyone! ! 〈/div>
〈div align=center>〈img src=/xx.gif>〈/div>
When some tables are many, texts are a lot, and the content is divided very carefully, people who like to use this method (the shortcut key in dw is ctrl+alt+c, I don’t know what FP is) often use it wildly. It’s a pity. When I encounter such a web page, I have a headache. Why do I need to use so many <div> to center it? tell me why? Does the table have no centering attribute? Why add these junk codes? When modifying it, you cannot delete the text or pictures and automatically clear it.
It is recommended to use <td align=center> to center. When multiple positioning is required, consider <div align=center>. Because this code is not easy to deal with, so if you can use a table instead, use a table instead.
3. Reuse code that implements the same function, or messy code
Probability of error: Very common
Universality: Very common
Possibility of making mistakes: complex and diverse
Let’s take a look at the following code:
〈center>〈p>〈font >〈font >〈font color=#cccccc>〈font color=#ffa76c style=font-size:14px;font-family:家家>〈/font>〈/font>〈/font>
〈/center>How do you think such a code looks like? 〈/font>〈/p>
I don’t know what readers feel. As soon as I see such a code, I will be numb for ten seconds. The purpose of these ten seconds is to find a word that can express my thoughts and feelings (me? Do you want to ask me back? sorry~~, I usually don’t make any mistakes, because I spend at least half of my time browsing code on web pages, and I can see that there are too many things in the code that shouldn’t be too much.).
Look at the above code. It uses 2 classes and 4 fonts to define 2 texts. In fact, such problems are often caused by people's constant modifications. People who are not familiar with the code, are lazy to view the code, or do not like to view the code, these problems are particularly serious. Of course, in fact, there is no problem when others browse this web page, but the person who maintains it......
These extra junk codes can be completely omitted. In fact, the above examples are not serious enough, and I have seen them even more terrifying.
Another question to be mentioned is 〈p>...〈/p> and 〈center>...〈/center>, why use them? tell me why~~, what is this:
〈td>〈div align=center>
〈center>
〈p align=center>〈/p>
〈p align=center>〈font >〈font >〈font color=#cccccc>〈font color=#ffa76c style=font-size:14px;font-family:家家>〈/font>〈/font>〈/font>
〈/center>〈/td>How do you think such a code looks like? 〈/font>〈/p>〈/center>〈/div>〈/td>
I will be helpless when I see such a code (even more helpless is that I often see it, and I have to read it). Let me simplify it:
〈td align=center >
〈font color=#ffa76c style=font-size:14px;font-family:家家>Title〈/font>
How do you think such a code looks like? 〈/td>
Do you seem to feel that the world is much quieter? The text completion after the title can be defined in the class of <td>. Even if you don't use css, it's okay to use an extra <.font>, it's still very refreshing.
4. The table is incorrectly nested
Probability of error: Normal
Universality: universal
Possibility of making mistakes: Don't know this
In fact, this is a problem of being aware of the streets, but people still keep making trouble. Incorrect nested forms may make you scolded by the boss in the office, and make you think that a normal web page cannot be opened for 2 or 3 minutes with adsl. Let’s talk about the first problem first, which is to constantly nest tables in a large table, which will slow down the speed of opening web pages (although the current ie has improved this problem, it is still not recommended to do this). On the other hand, maintenance and modification are also extremely inconvenient. Generally speaking, there is no problem with simple application, even layers 3 or 4, but do not put all the content in one table. The second problem is to put everything in a large table, and it includes a free counter code. Hehehe, guess what is possible? In fact, it's no big deal. The most serious thing is that your ie is like a crash and nothing is displayed. The solution is to put the counter in a single table and not in the same table as other contents.
5. When writing code indentation, use not tabs but spaces
Probability of error: Normal
Universality: Less
Possibility of making mistakes: I don't know that tab is better
This question is for js, vbs, asp, php, etc. If you cannot use tab, you can write a little program, you know what indent is and how to indent? Some people use spaces, some people use tabs, if you use spaces, then switch to tabs from now on.