<td align="left" valign="top"> Why does this generate no error in the W3C validator?

5.4k views Asked by At
<td align="left" valign="top"> 

Generates no validation errors, does it mean both are valid?

3

There are 3 answers

4
kennytm On BEST ANSWER

Why error? One is align (horizontal alignment), one is valign (vertical alignment), both can present.

From http://www.w3.org/TR/xhtml-modularization/abstract_modules.html#s_tablemodule, the attributes of <td> contain align ("left" | "center" | "right" | "justify" | "char") and valign ("top" | "middle" | "bottom" | "baseline")

0
DisgruntledGoat On

you have posted dozens of very similar questions, asking about every minute aspect of HTML validation, deprecated tags and so on. I think you need to stop worrying whether specific HTML snippets validate or not.

First, relying on a single metric (validation) for code quality is not good. Second, valid code is not always good code. You could nest 500 div tags with meaningless class names and it would validate, but it would be horrible code.

Is validation bad? No, of course not. It can help pick out problems that may appear cross browser. Things like mis-typed attributes, certain unclosed tags (like divs). But for example using <br> instead of <br/> in an XHTML document doesn't matter - browsers treat them identically.

Please take a little time to learn about the separation of HTML for content and CSS for presentation. Then you'll see how obvious the answer for your question is. If the validator isn't complaining about some attributes, then that doesn't automatically mean they are great and should be used liberally.

Think about what the attributes are doing. They are aligning content horizontally and vertically. That's a presentational issue, therefore, it is better to put them in CSS where possible.

Sorry for the rant, but I hope you can see my point and stop relying on the w3c validator for everything.

0
LiamGu On

If it's really a worry, could you not use CSS instead, so you have:

<td class="myclass">

and then some CSS to align it? Surely that's more acceptable to do then your example?