Home > Article > Web Front-end > Five common HTML mistakes in web design
1.网页背景色的设置
犯错机率:很大
普遍性:较广
犯错可能性:懒/不知道
约2年前我曾发现21cn上出现过一次没有设置背景色的情况,当时我用Email通知了他们,自此之后这个问题我从没犯过。
绝大部分人的窗口背景颜色都是白色,但如果象我这样个性的人,就会把windows窗口的背景颜色改成灰色或其他色,这样一来,如果你没有设置网页的背景颜色的话,你以为正常的网页在我的电脑上看起来会是一团糟。
2.Align center(自动居中)的滥用
犯错机率:非常大
普遍性:非常广
犯错可能性:以为方便/以为好用
工作中,修改、维护别人的网页是家常便饭,发现不少人有一个陋习:
在表格中的文字或图片,你是这样来令它居中、靠左或靠右过?
当有些表格很多、文字很多、内容分得很细的时候,爱用这种方法(它在DW里的快捷键是Ctrl+Alt+C,FP不知道是什么)的人往往会狂用,惨了,我一碰到这样的网页就头痛,为什么要用那么多
建议使用
3.重复使用实现相同功能的代码、或杂七杂八的乱套代码
犯错机率:非常普遍
普遍性:非常普遍
犯错可能性:复杂多样
大家先来看一看下面的代码:
标 题
我不知道读者有什么感觉,压根我一看到这样的代码就会先自我麻木十来秒,这十来秒目的是为了找一个能表达我的思想感情的词(我?你想反问我吗?sorry~~,我一般不犯,因为我做网页至少有一半以上的时间在浏览代码,代码中多了不该多的东西我一眼就能看出来。)。
看看上面的代码,使用了2个class,4个font来定义2个文本,其实这样的问题很多时候是在大家不断的修改中产生的,对代码不熟、或懒查看代码、又或不喜欢查看代码的人犯这些问题特别严重,当然,事实上别人浏览这个网页的时候,是没有任何问题的,但维护的人就…………。
这些多余的垃圾代码完全是可以省略掉的,其实上面的例子不够严重,更恐怖的我都见过。
另外还有一个问题也要提提的,就是
...
和
标 题
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:
Does it seem like the world is a lot quieter? The text after the "title" can be defined in the class of
4. The tables are not nested correctly
Probability of error: General
Prevalence: Common
Possibility of error: Don’t know about this
In fact, this is a well-known problem, but people still make it , incorrect nesting of tables may cause you to be called to the office by your boss to give you a scolding, and may make you 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
Chance of making mistakes: average
Universality: 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.
天极yesky
The above are the contents of five common HTML errors in web design. For more related articles, please pay attention to the PHP Chinese website (www.php.cn)!