FRIHOSTFORUMSFAQTOSBLOGSDIRECTORY
You are invited to Log in or Register a Frihost Account!

Strict XHTML 1.0 Validation problem

 


riyadh
i validated my pages with the strict xhtml 1.0 standards but there is one error i cannot get rid of.in the strict xhtml guidlines, the 'align' attribute in the '<table>' element has been dropped.they suggest that i use styles instead of 'align'.how do i do that?
mathiaus
text-align: [left|center|right|justify]

eg 1
Code:
<table style="text-align:center;"><tr><td>content</td> {other td's}</tr> {other rows}</table>


eg 2
Code:
table { text-align: center; }
dayveday
I think the align element actually causes the table to be placed in the centre of the page, rather than the text inside it to be centred? Is that right?

In that case, you'd need to use:
Code:
<table style="margin: 0 auto;">....</table>


The margin property there tells the browser to use no margin above or below the table, and 'auto' to the left and the right (this will cause it to be centred).

Hope it helps.
welshsteve
If you wish text within a table to be centered, you need to apply the text-align:center to the td tags.

Here's an example of a table centred at the top of a page with text centered in each cell.

Code:

<!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>
   <title>Test</title>
   <style type="text/css">
   <!--
   table { margin: 0 auto; border-collapse: collapse; border: 1px solid #000; }
   td { text-align: center; padding: 10px; border: 1px solid #000; }
   -->
   </style>
   </head>
<body>
<table>
   <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>
   <tr>
      <td>Cell 7</td>
      <td>Cell 8</td>
      <td>Cell 9</td>
   </tr>
</table>
</body>

</html>

Reply to topic    Frihost Forum Index -> Scripting -> Html, CSS and Javascript

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2007 Frihost, forums powered by phpBB.