2015-12-08 62 views
0

我正在練習html電子郵件並試圖居中文本。但它不起作用。我也懷疑這是行不通的,因爲我在字體標籤中使用了style標籤。我已經在validator.w3.org測試了我的代碼,並通過了它。這段代碼有什麼問題。請幫助我將文本對齊到中心。text-align = center不工作

Doctype is : <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<tr> 
 
    <td> 
 
    <font style="font-family: verdana; font-size:10px; font-weight: bold; text-align: right;"><i> 
 
"We are such stuff as dream are made on, and our little life is rounded with a sleep" William Shakespeare</i> 
 
\t \t </font> 
 
    </td> 
 
</tr>

+0

這篇文章可能會有所幫助... http://stackoverflow.com/questions/9989657/html-email-align-text – TomKorec

回答

0

那是你糾正代碼:

<table width="100%"> 
 
<tr> 
 
    <td style="text-align: right;"> 
 
    <font style="font-family: verdana; font-size:10px; font-weight: bold;"><i> 
 
"We are such stuff as dream are made on, and our little life is rounded with a sleep" William Shakespeare</i> 
 
\t \t </font> 
 
    </td> 
 
</tr> 
 
</table>

+0

對不起,我測試了代碼,通過使文本對齊到正確的地方,看看它是否工作。在發佈之前,我忘了將它改回中心位置。 – Sharmile

+0

謝謝你Gabriel。因此,當我在中插入時,text-align正常工作。就像你在代碼中提到的一樣。你知道爲什麼當我們把字體放在字體裏時,它不起作用。 – Sharmile

+0

「CSS中的文本對齊屬性用於對齊**塊**元素的內部內容。」 (https://css-tricks.com/almanac/properties/t/text-align/)是一個內聯元素,因此不應該使用text-align屬性。 –