我试图使用一个有效的文档类型,但是如果我使用下面的URL,链接拒绝维护在200宽度表中分配的#ffffff
文本颜色(和)背景颜色擦除所有通过两行(谷歌和雅虎链接)。注释掉Doctype URL,它工作得很好…有谁能给我一些启示吗?
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>test.com</title>
<style type="text/css">
td.off{background: #223C66}
td.on{background: #2d2dff}
</style>
<style>
a{text-decoration:none}
a:hover{text-decoration:underline}
</style>
</head>
<table width="600" align="center" style="border:10px solid black; border-collapse:collapse;" cellpadding="10" cellspacing="0">
<tr>
<td>
<table width="200" cellpadding="0" cellspacing="10" border="0">
<tr>
<td height="40" class="off" onmouseover="this.className='on'" onmouseout="this.className='off'">
<a href="http:\www.google.com"><font color=#ffffff size=2 face=arial>valid google link</font></a>
</td>
</tr>
<tr>
<td height="40" class="off" onmouseover="this.className='on'" onmouseout="this.className='off'">
<a href="http://www.yahoo.com" target="_blank"><font color=#ffffff size=2 face=arial>valid yahoo link</font></a>
</td>
</tr>
</table>
</td>
<td style="border:1px solid black; border-collapse:collapse;" cellpadding="0" cellspacing="0">
<a href="http:\www.msn.com">valid msn.com link</a>
<p>plain test - no link</p>
</td>
</tr>
</table>
</body>
</html>
您需要确保所有属性值都用"
引号包装,以便有效。
,
<font color="#ffffff" size="2" face="arial">
另外,在标记上使用验证工具也是一种很好的实践:W3C标记验证服务http://validator.w3.org/check
添加:完整版本与适当的标记,应该验证为HTML 4.01过渡
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>test.com</title>
<style type="text/css">
td.off {
background: #223C66;
}
td.on {
background: #2d2dff;
}
a {
text-decoration:none;
}
a:hover {
text-decoration:underline;
}
</style>
</head>
<body>
<table width="600" align="center" style="border:10px solid black; border-collapse:collapse;">
<tr>
<td>
<table width="200" border="0">
<tr>
<td height="40" class="off" onmouseover="this.className='on'" onmouseout="this.className='off'">
<a href="http://www.google.com"><font color="#ffffff" size="2" face="arial">valid google link</font></a>
</td>
</tr>
<tr>
<td height="40" class="off" onmouseover="this.className='on'" onmouseout="this.className='off'">
<a href="http://www.yahoo.com" target="_blank"><font color="#ffffff" size="2" face="arial">valid yahoo link</font></a>
</td>
</tr>
</table>
</td>
<td style="border:1px solid black; border-collapse:collapse;" >
<a href="http://www.msn.com">valid msn.com link</a>
<p>plain test - no link</p>
</td>
</tr>
</table>
</body>
</html>