1. Setting the background color of the web page Chance of making a mistake: Very high Universality: Broad Possibility of making mistakes: Lazy/don’t know About 2 years ago, I discovered that the background color was not set on 21cn. At that time, I notified them by email. Since then, I have never had this problem. 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) Chance of making a mistake: Very high Universality: Very broad Possibility of making mistakes: thinking it’s convenient/thinking it’s easy to use 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> When there are a lot of tables, a lot of text, and very detailed content, people who like to use this method (its shortcut key in DW is Ctrl+Alt+C, FP doesn’t know what it is) often use it wildly, and it’s miserable. Sorry, I get a headache every time I encounter a webpage like this. 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 text or pictures and it will be automatically cleared. It is recommended to use <td align="center"> for centering. When multiple positioning is required, only consider <div align="center">. Because this code is not easy to handle, use a table instead if you can. 3. Repeated use of code that implements the same function, or miscellaneous messy code. Error probability: very common Universality: Very common Possibility of error: complex and varied Let’s take a look at the following code first: I don’t know how readers feel. Basically, when I see such code, I will numb myself 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 my time browsing the code, and I can tell at a glance that there are too many things in the code.) Take a look at the above code. It uses 2 classes and 4 fonts to define 2 texts. In fact, such problems often arise when people are constantly modifying them. They are not familiar with the code, or are too lazy to check the code, or do not understand 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 are no problems, but the maintainers... 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 cases are like this: <td><div align="center" class="css_id"> I feel helpless when I see code like this (and what’s even more helpless is that I often see it and must read it). Let me simplify it: Doesn’t it seem like the world is a lot quieter? The text after 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.Tables are not nested correctly Chance of making mistakes: average universality: universal Possibility of error: Don’t know about this In fact, this is a well-known problem, but people still make it. Incorrect nested tables may get you called into the office by your boss and give you a scolding. It may make you think that normal web pages use ADSL. It can't be turned on even after 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 don't 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. Chance of making mistakes: average Prevalence: less Possibility of making mistakes: I don’t know that Tab is better to use This question is for js, vbs, asp, php, etc. HTML cannot use Tab. Anyone who 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
<div align="center"><img src="xx.gif"></div>
<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>
These redundant junk codes can be completely omitted. In fact, the above examples are not serious enough. I have seen even scarier ones.
<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>
<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>