2016-07-22 46 views
-2

我正在嘗試爲我的小型啓動製作網站。現在的事情是我想要製作一個背景顏色爲白色的中心區域和一個背景顏色爲淺灰色的區域。我製作了一張背景顏色爲白色的桌子,並將其對齊在中間,但它只出現在頁面的底部。發生什麼事?HTML內容未出現在表

<html> 
<head> 
<title>Memocups</title> 

</head> 
<body bgcolor="#d9d9d9"> 
<table align="center" width="50%" bgcolor="#ffffff"> 
<tr> 
<p><h1>Memocups</h1><p> 
<p><h3>What is a memocup?<h3><p> 
    <img src="images/img_1_cuponstump.jpg" width="540px" height="360px"> 
<p> 
    A memocups is a coffe mug wich has a customizable picture!<br> What makes memocups unique from all other mugs with pictures is <br>that you upload the picture you want to our website and we<br> will put it on the mug! So what are you waiting for the<br>perfect gift is only a few clicks away!</p> 
</tr> 
</table> 
</body> 
</html> 
+2

這不是一個表格式正確,你就錯過了'td' [看看這裏(http://www.w3schools.com/html/html_tables .asp的)。此外,除非您正在佈置表格數據,否則應該避免使用表格。 – APAD1

+0

你的HTML無處不在。 – j08691

+0

從這裏開始:http://validator.w3.org/nu/ – Quentin

回答

0

簡單的表格有三列兩行。

<table border=1> 
 

 
    <tr> 
 
     <td>cell 1<td> 
 
     <td>cell 2</td> 
 
     <td>cell 3</td> 
 
    </tr> 
 

 
    <tr> 
 
     <td>cell 4<td> 
 
     <td>cell 5</td> 
 
     <td>cell 6</td> 
 
    </tr> 
 

 
</table>

0

下面是表應該如何格式化:

<table width="50%" style="background-color:#fff;margin:0 auto;"> 
 
\t <tr> 
 
\t \t <td> 
 
\t \t \t <h1>Memocups</h1> 
 
\t \t \t <h3>What is a memocup?</h3> 
 
\t \t \t <img src="images/img_1_cuponstump.jpg" width="540px" height="360px"> 
 
\t \t \t <p>A memocups is a coffe mug wich has a customizable picture!<br> What makes memocups unique from all other mugs with pictures is <br>that you upload the picture you want to our website and we<br> will put it on the mug! So what are you waiting for the<br>perfect gift is only a few clicks away!</p> 
 
\t \t </td> 
 
\t </tr> 
 
</table>

我刪除了p標籤,你必須在你的標題,因爲他們是沒有必要的。另請注意,bgcoloralign已被棄用,您應該使用background-colormargin/float CSS。還糾正了未封閉的h3標籤並添加了td(表格單元格)。

也就是說,表格不是用於此數據的正確元素。你應該使用div。

+0

由於這是一個佈局表格(與數據表格相對),因此我會在table元素中添加屬性'role =「presentation」'。 (有關背景信息,請參閱W3C規範草案[關於在HTML中使用ARIA的注意事項](https://www.w3.org/TR/aria-in-html/#use-of-role-presentation)。) –