1. The probability of making mistakes when setting the background color of a webpage
: very
common: relatively wide.
The possibility of making mistakes: lazy/don’t know.
About 2 years ago, I found that the background color was not set once on 21cn. At that time, I notified it by email. They, I have never had this problem since.
The background color of most people's windows is white, but if you are a person like me, you will change the background color of the windows window to gray or other colors. In this way, if you do not set the background color of the web page, What you'd think would be a normal web page would look like a mess on my computer.
2. Abuse of Align center (automatic centering)
Probability of error: Very high
Prevalence: Very high
Probability of error: Thinking it is convenient/thinking it is useful
At work, it is common to modify and maintain other people’s web pages. I found that many people have a bad habit:
How do you center, left, or right the text or images in the table?
<div align="center">Hello everyone! ! </div>
<div align="center"><img src="xx.gif"></div>
When there are many tables, a lot of text, and the content is very detailed, I like to use this method (its shortcut in DW (The key is Ctrl+Alt+C, FP doesn’t know what it is) people tend to use it like crazy. It’s terrible. I get a headache when I encounter such a web page. Why do I need to use so many <div>s to center it? tell me why? Doesn't the table have a centered property? Why add this junk code? When making special modifications, you cannot delete the text or image and it will be automatically cleared.
It is recommended to use <td align="center"> to center. When multiple positioning is required, only consider <div align="center"> because of this code It's not easy to handle, so if you can use a table instead, use a table instead.
3. Reuse code that implements the same function, or miscellaneous messy code. Error probability: very common.
Universality: very common.
Error probability: complex and diverse.
Let’s take a look at the following code first:
<center><p><font class="css_id"><font class="font11"><font color="#CCCCCC"><font color="#FFA76C" style="font-size:14px;font- family:official script">Title</font></font></font>
</center>What do you think this code looks like? </font></p>
I don’t know how readers feel. Basically, when I see such code, I will be numb for about 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 generally don’t do this, because I spend at least half of the time browsing the code when making web pages. I can tell at a glance that there are too many things in the code that shouldn’t be there.).
Take a look at the code above. 2 classes and 4 fonts are used to define 2 texts. In fact, such problems often occur when people are constantly modifying them. They are not familiar with the code, are too lazy to check the code, or are not familiar with the code. People who like to check the code are particularly guilty of these problems. Of course, in fact, when others browse this web page, there is no problem, but the maintainers...
These redundant garbage codes can be completely omitted. In fact, the above examples are not serious enough. I have seen even scarier ones.
There is another question that needs to be mentioned, which is <p>...</p> and <center>...</center>. Why should we use them? tell me why~~, some people are like this:
<td><div align="center" class="css_id">
<center>
<p align="center"></p>
<p align="center"><font class="css_id"><font class="font11"><font color="#CCCCCC"><font color="#FFA76C" style="font-size:14px; font-family:official script">Title</font></font></font>
</center></td>What do you think this code looks like? </font></p></center></div></td>
I will be very helpless when I see such code (even more helpless is that I often see it and must read it), let me simplify it. :
<td align="center" class="css_id">
<font color="#FFA76C" style="font-size:14px;font-family:official script">Title</font>
What do you think this code looks like? </td>
Does it seem like the world is a lot quieter? The text behind the "title" can be defined in the class of <td>. Even if you don't use css, it's no problem to use an additional <.font>. It's still very refreshing.
4. Incorrect nesting of tables.
Probability of making mistakes: General
prevalence: Common
possibility of making mistakes: Don’t know about this.
In fact, this is a common problem, but people still make it. Incorrect nesting of tables may cause You will be called into the office by your boss and scolded, and you will think that a normal web page cannot be opened even if you use ADSL for 2 or 3 minutes. Let’s talk about the first problem first, which is that continuously nesting tables in a large table 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). In addition, On the one hand, it is extremely inconvenient to maintain and modify. Generally speaking, there is no problem with simple application, even 3 or 4 layers, but do not put everything into a table. The second problem is to put everything in a big table, including a free counter code, hehe, guess what might happen? In fact, it's not a big deal. The most serious thing is that your IE seems to have crashed and nothing is displayed. The solution is to put the counter in a separate table, not in the same table with other content.
5. When writing code indentation, use spaces instead of Tabs
. Probability of making mistakes: Generally
common: Less
likely to make mistakes: I don’t know if Tab is better.
This question is for js, vbs, asp, php, etc., html Anyone who can’t use Tab and knows how to write some programs knows what indentation is. How to indent? Some people use spaces, some use Tab. If you use spaces, then from now on, use Tab instead.
tianjiyesky