Home >Web Front-end >HTML Tutorial >来帮我看看这个html 表格边框颜色怎么弄_html/css_WEB-ITnose
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>无标题文档</title></head><style type="text/css"><!--.news table td{border:1px solid #F00;}.bac table td{border:1px solid #00F;}--></style><body><table width="658" height="317" border="0" cellspacing="0px" class="bac" style="border-collapse:collapse" align="center" id="t1"> <tr> <td>1</td> <td>2</td> </tr> <tr> <td colspan="2"><table width="50%" border="0" align="center" class="news" id="t2"> <tr> <td>3</td> <td>4</td> <td>5</td> </tr> <tr> <td> </td> <td> </td> <td> </td> </tr> <tr> <td> </td> <td> </td> <td> </td> </tr> </table></td> </tr></table></body></html>
楼主,你理解的CSS的优先级有误啊,把你的CSS代码改成如下就可以了:
<style type="text/css"> table.bac td{ border:1px solid #00f; } table.news td{ border:1px solid #F00; } </style>
<style type="text/css"> #t1 td{ border:1px solid #00f; } #t2 td{ border:1px solid #F00; } </style>