2
<td align="left" valign="top"> 

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

Paul Sweatte
  • 24,148
  • 7
  • 127
  • 265
Jitendra Vyas
  • 148,487
  • 229
  • 573
  • 852
  • Does it matter much? If you care about semantic markup (you most likely do if you are using XHTML 1.1), you do not want/need those attributes anyway. – Jørn Schou-Rode Mar 11 '10 at 06:45

3 Answers3

6

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.

DisgruntledGoat
  • 70,219
  • 68
  • 205
  • 290
2

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")

kennytm
  • 510,854
  • 105
  • 1,084
  • 1,005
  • @KennyTM: I think the OP expects an error as he is using XHTML (cf. tags), and this doc type generally discourages layout information in the markup. – Jørn Schou-Rode Mar 11 '10 at 06:43
  • Then W3C validator isn't the right tool. It won't even reject the `` tag because it is in the schema. – kennytm Mar 11 '10 at 07:11
  • 1
    @Jørn XHTML doesn't discourage anything. It's a reformulation of HTML4 in XML. Separation of presentation and content is a design philosophy, not a W3C spec. – mercator Mar 11 '10 at 09:00
  • 1
    XHTML 1.0 is. XHTML 1.1 introduces some changes. *Some* of which are even documented in the Changes from XHTML 1.0 Strict section. – Quentin Mar 11 '10 at 09:19
0

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?

LiamGu
  • 5,317
  • 12
  • 49
  • 68