如何在html中的一个单元格中使用多个链接

时间:2015-10-09 12:35:57

标签: html html-table cell

我的问题是如何在一个单元格中使用多个链接?

我的html视图就是这个,我希望在家里有产品链接,并与我们联系。

我的作业是设计一个带桌子的网站:

enter image description here

我的代码是:

<!doctype html>
<html>
<head>
<style>
table {
    border: 1px solid black;
    border-collapse: collapse;
    border-spacing: 5px;
}
th, td {
    padding: 10px;
}
</style>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>

<body>

<table style="width:100%" border="1px" cellpadding="5" cellspacing="5" bordercolor="green" bgcolor="yellow" height="500px">
<caption>web design homework</caption>
<tr>
<th colspan="3">My Website</th>
</tr>
<tr  bgcolor="#77E022"
height="20px" align="left" >
<td  colspan="3" >  home  &nbsp;&nbsp;&nbsp;   products   &nbsp;&nbsp;&nbsp;   contact us  
 </td>
</tr>
<tr>
<td width="25%"> last post </td>
<td rowspan="2" width="50%"> hello my name is mohammad ghorbani and i am studying computer enginerring in arak </td>
<td> our friends </td>
</tr>
<tr>
<td> our statics </td>
<td> 24 </td>
</tr>
</table>

</body>
</html>

5 个答案:

答案 0 :(得分:2)

&#13;
&#13;
table {
    border: 1px solid black;
    border-collapse: collapse;
    border-spacing: 5px;
}
th, td {
    padding: 10px;
}
&#13;
<table style="width:100%" border="1px" cellpadding="5" cellspacing="5" bordercolor="green" bgcolor="yellow" height="500px">
  <caption>web design homework</caption>
  <tr>
    <th colspan="3">My Website</th>
  </tr>
  <tr  bgcolor="#77E022" height="20px" align="left" >
    <td  colspan="3" >
      <a href="/home">home</a>
      <a href="/products">products</a>
      <a href="/contact">contact us </a>
   </td>
  </tr>
  <tr>
    <td width="25%"> last post </td>
    <td rowspan="2" width="50%"> hello my name is mohammad ghorbani and i am studying computer enginerring in arak </td>
    <td> our friends </td>
  </tr>
  <tr>
    <td> our statics </td>
    <td> 24 </td>
  </tr>
</table>
&#13;
&#13;
&#13;

答案 1 :(得分:1)

只需添加指向您文字的链接,例如更改:

contact us

<a href="www.google.com">contact us</a>

答案 2 :(得分:1)

喜欢这样:

<a href="url1"> home </a>  &nbsp;&nbsp;&nbsp;   <a href="url2"> products </a>  &nbsp;&nbsp;&nbsp;   <a href="url3"> contact us </a>  

答案 3 :(得分:1)

只需添加锚标记并在css下面

 <a href="#">home</a>
 <a href="#">products</a>
 <a href="#">contact us </a>

的CSS:

a { 
text-decoration:none;
}

答案 4 :(得分:1)

<a href="home">home</a>
  <a href="products">products</a>
  <a href="contact">contact us</a>

使用上面的代码替换下面的代码

<td  colspan="3" >  home  &nbsp;&nbsp;&nbsp;   products   &nbsp;&nbsp;&nbsp;   contact us