Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What is default align in <td>?

Status
Not open for further replies.

stranger123

Programmer
Apr 16, 2006
76
GB
I have tested the following code that the string "aaaaaaaaaaa" was displied at the center. However, if I remove <!DOCTYPE......loose.dtd">, the string would be displied at the left.
Do you think I missed something or it the designed behaviour?

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"
<table width="100%" border=1>
<tr><td align="center">

<table width="90%" border=1>
<tr><td>aaaaaaaaaaa</td></tr>
</table>

</td></tr>
</table>
 
Do you think the alingment in a <td> inherits the alignment in the father table?
 
Default horizontal alignment for td is left, as was mentioned, default vertical alignment is middle. However, all html elements will always inherit the text alignment from their parents. That said, there is really no need to nest tables.
 
Vragabond,

In fact I want all <td>s use left alignment except align=center is inserted. However, after adding the <!DOCTYPE......loose.dtd">, the rule changed, I need to change my code a lot.
BTW, I nexted tables not for alignment setting.
 
However, that will change <td align="center"> in my code to align="left"!!
 
Then change
Code:
<td align="center">

to
Code:
<td class="center">

and use
Code:
<style type="text/css">
<!--
td {
    text-align: left;
}
.center {
    text-align: center;
}
-->
</style>

There are many ways to attack the situation.

M. Brooks
 
That may work, I will try.

So, you believe using <!DOCTYPE......loose.dtd"> will change the alignment setting behaviour?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top