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!

Won't validate 2

Status
Not open for further replies.

pindky

Programmer
Apr 26, 2002
101
US
Hello,

The following code won't validate as XHTML and I don't know why. What is wrong with it?

------
<table cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; width=&quot;100%&quot; align=&quot;center&quot; bgcolor=&quot;#000066&quot; border=&quot;0&quot;>
<tr>
<td valign=&quot;middle&quot;>
<!-- Begin Right Search Site Table -->

<table cellspacing=&quot;1&quot; cellpadding=&quot;10&quot; width=&quot;100%&quot; border=&quot;0&quot;>
<tr>
<td valign=&quot;top&quot; align=&quot;center&quot; bgcolor=&quot;#F0F0FF&quot;>
<!-- Begin Free Find -->
<form action=&quot; method=&quot;get&quot; target=&quot;_self&quot;>
<input type=&quot;hidden&quot; name=&quot;id&quot; size=&quot;-1&quot; value=&quot;48514865&quot; />
<input type=&quot;hidden&quot; name=&quot;pageid&quot; size=&quot;-1&quot; value=&quot;r&quot; />
<input type=&quot;hidden&quot; name=&quot;mode&quot; size=&quot;-1&quot; value=&quot;all&quot; />
<input type=&quot;hidden&quot; name=&quot;n&quot; value=&quot;0&quot; />
<span class=&quot;nav&quot;>Search Site:</span><br /><br />
<label for=&quot;enter_keywords&quot;><input type=&quot;text&quot; name=&quot;query&quot; input id=&quot;enter_keywords&quot; size=&quot;20&quot; value=&quot;Enter Keywords Here&quot; accesskey=&quot;k&quot; /></label>
<br /><br /><label for=&quot;submit&quot;><input type=&quot;submit&quot; input id=&quot;submit&quot; name=&quot;submit&quot; value=&quot;Search Site&quot; accesskey=&quot;s&quot; /></label>
<br />
<br />
<a href=&quot; title=&quot;FreeFind Website&quot; class=&quot;pagelinks&quot;>Powered by FreeFind</a></form>
<!-- End Free Find-->
</td>
</tr>
</table>
<!-- End of Right Search Site Table -->
</td>
</tr>
</table>
------------------
 
1. you have a semi-colon after:

<form action=&quot;
and

<a href=&quot;
2. You have a minimized attribute (&quot;input&quot;) which is illegal in XHTML in 2 places:

input type=&quot;text&quot; name=&quot;query&quot; input id=&quot;enter_keywords&quot;

and

<input type=&quot;submit&quot; input id=&quot;submit&quot;

3. Depending on the level of XHTML compliance, attributes like &quot;bgcolor&quot; and &quot;align&quot; are not permitted.

Good luck.
 
Is there supposed to be any semi-colon at all after the URL?

Also what is meant by the term minimized attribute? What should the code look like?

Thanks!

 
>>Is there supposed to be any semi-colon
>>at all after the URL?
No. If you did not put it in, then this forum application may have incorrectly inserted it. So, no semi-colon.

>>Also what is meant by the term minimized attribute?
A minimized attribute looks like this:

<element attribute />

instead of a regular attribute that that looks like this:

<element attribute=&quot;&quot; />

HTML 4 uses a minimized attribute in to indicate a checkbox is checked. For example:

<input type=&quot;checkbox&quot; checked>


>>What should the code look like?
This code:
<input type=&quot;submit&quot; input id=&quot;submit&quot; name=&quot;submit&quot; value=&quot;Search Site&quot; accesskey=&quot;s&quot; />

Should look like this:
<input type=&quot;submit&quot; id=&quot;submit&quot; name=&quot;submit&quot; value=&quot;Search Site&quot; accesskey=&quot;s&quot; />
 

pindky,

>> The following code won't validate as XHTML and I don't know why.

Surely the validator told you what was wrong with it when it told you it wasn't valid?

Anyway - here's a summary:

1. Remove
Code:
align=&quot;center&quot;
from the table definition
2. Change your
Code:
bgcolor
attributes (table and td definition) to
Code:
style=&quot;background-color:#xxxxxx;&quot;
(migrate to CSS)
3. Wrap your form contents in a
Code:
<div>
tag (or other such element). If you place the open
Code:
<div>
tag right after the open
Code:
<form>
tag, and the closing
Code:
</div>
tag right before the closing
Code:
</form>
tag, that should work.
4. Remove the lone &quot;input&quot; attribute from your query text input field and submit button field.
5. Remove the target from the form action.

Doing all that should clear your errors up.

I still find it strange that the validator wasn't clear about why your code wasn't validating... They normally give pretty good feedback as to exactly what the problems are.

Hope this helps,

Dan



 
BillyRayPreachersSon, everything you mentioned is right on but it is best not to use inline CSS. It is deprecated in the latest XHTML spec. It's better to use embedded or external CSS. The &quot;style&quot; attribute is just as bad the &quot;font&quot; element because it fuses formatting and content together.
 

>> It is deprecated in the latest XHTML spec.

You're saying that the &quot;style&quot; attribute no longer validates when using XHTML 1.0 (the latest XHTML spec)?

That is kind of strange, as I have (in the last day) validated 2 new sites using XHTML 1.0... Both have inline CSS, and both validate fine (against the strict DTD).

As far as I can tell from the W3C site, XHTML 1.0 is the latest spec... What version/spec are you looking at?

Dan
 

How strange - don't know why I said 1.0 was the latest version, as I'm using 1.1 myself (it is early morning here ;o)... But anyway, using 1.1, the inline style attribute still validates perfectly well using the strict DTD.

*shrug*

Dan
 
Hi Dan,

The code should still validate in 1.1 with the style attribute. I meant that the style attribute is &quot;deprecated&quot; - a outdated construct whose use is strongly discouraged. They might bring it back in 2.0 but that is only because of SVG or for political reasons. I came across this article a while back that explains why we should not use inline CSS (style attribute).


I've started using 1.1 and I haven't looked back.
 

If they've deprecated it, surely pages that are using the XHTML 1.1 Strict DTD wouldn't validate using include styles (as mine do)?

Dan
 
I have checked the XHTML 1.1 Strict and early drafts for XHTML 2.0 specs and there is no mentioning that style attribute is deprecated. I personally think it would be stupid to get rid of this attribute since it does serve a purpose. It is used to perform individual style changes in an element. If you do not wish to repeat such style changes anywhere else it is rather silly to make a class for it. That's my opininon at least.
 
There's no such thing as &quot;XHTML 1.1 Strict&quot;. There's XHTML 1.0 Strict, and there's XHTML 1.1 (which is even stricter). The permitted entities in XHTML 1.1 are listed at , and you'll see (if you scroll down) that the style attribute is indeed deprecated.

Documents that include deprecated tags will still validate as they're still valid tags. W3C just think you shouldn't use them. Try validating a XHTML 1.0 Transitional document with a <font> tag, for example.

That said, I agree with Vragabond that the style attribute is too useful to get rid of, for debugging if nothing else. Frankly, I wouldn't worry about it. XHTML 1.1 is the end of the line. XHTML 2.0 is not going to be backward compatible with it, so if any browser ever supports 2.0 and not 1.x style attributes will be the least of our problems. Fortunately, we'll all have retired by then!

-- Chris Hunt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top