PDA

View Full Version : XHTML Validation


Cheng
08-13-2006, 03:39 AM
Hi.

When I check the XHTML code on the web there is among other errors this one:
The character encoding specified in the HTTP header (windows-1252) is different from the value in the <meta> element (iso-8859-1). I will use the value from the HTTP header (windows-1252) for this validation.
But I can't find the entry (windows 1252) in the header.
Could someone please point this out to me so I can fix the error?
And what is the difference between:
XHTML 1.0 Strict and XHTML 1.0 Transitional?

Thank you very much.

Cheng
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>First Future Corporation - Home</title>
<meta name="Keywords" content="keywords goes here" />
<meta name="Description" content="description goes here. " />
<meta name="author" content="First Future Corporation" />
<meta name="copyright" content="First Future Corporation - 2005-2006" />
<meta name="distribution" content="global" />
<meta name="robots" content="all" />
<meta name="rating" content="general" />
<meta http-equiv="content-language" content="en" />
<link rev="made" href="info@first-future.com" />
<link href="/styles/layout.css" media="screen" rel="stylesheet" />
<link href="styles/layout.css" rel="stylesheet" type="text/css" />

jscheuer1
08-13-2006, 07:58 AM
Unless I am mistaken, the HTTP header is sent by the server and may have nothing to do with what you write on your page. In regular HTML it should, but in XHTML things are probably a bit different, it may be server dependant or influenced by the DTD or the xmlns. Your document would probably be better off as regular HTML anyway.

Cheng
08-13-2006, 08:20 AM
Hi John.

I'm nearly done with it there is only one more validation error I have to get rid of.
Maybe you can help me out here.
The error is in this tag here marked in red:
<script>FlashLoad(7,'TopMenu_on_en.swf','#fff',780,120);</script>

Someone helped with this code here but it wont load the swf file:
<script type="text/javascript">flashload(7,'TopMenu_on_en.swf','#fff',780,120); </script>

Would be great if you could help me with this piece of code so that it will load the swf and the the validator wont show an error as well.

Thank you very much.

Cheng

jscheuer1
08-13-2006, 09:19 AM
While important to the validator, using the type attribute or not shouldn't make any difference to most browsers. But, if you tried it with the wrong function name (function names are case sensitive) it wouldn't work in any browser:

<script>FlashLoad(7,'TopMenu_on_en.swf','#fff',780,120);</script>

<script type="text/javascript">flashload(7,'TopMenu_on_en.swf','#fff',780,120); </script>

Cheng
08-13-2006, 12:29 PM
Hi John.

Thanks, that was about kapital letters.
I got it now and every Page validated a 100% and on the validation page it says that if I want to I can put the WC3 sign on every page.
There is only one page that has not validated and that is a page that has a PayPal button on it.
Would it be ok to change these tags in an encrypted button?
It would be great if you or someone else could show me how to correct the tags in that button.

Thank you very much in advance.

Cheng
Here are the errors marked in red:
Line 39 column 91: required attribute "alt" not specified.
...rag (4).gif" width="80" height="80" /></p>

Line 48 column 92: document type does not allow element "form" here; missing one of "object", "applet", "map", "iframe", "ins", "del" start-tag.
...l.com/cgi-bin/webscr" method="post" />

Line 49 column 50: end tag for "input" omitted, but OMITTAG NO was specified.
<input type="hidden" name="cmd" value="_s-xclick">

Line 49 column 0: start tag was here.
<input type="hidden" name="cmd" value="_s-xclick">

Line 50 column 82: there is no attribute "border".
...ure.com/images/OrderHier.gif" border="0" name="submit" alt="Ordern Sie hier,

Line 50 column 146: end tag for "input" omitted, but OMITTAG NO was specified.
...rn Sie hier, sicher und problemlos!">

Line 50 column 0: start tag was here.
<input type="image" src="http://www.first-future.com/images/OrderHier.gif" borde

Line 51 column 95: end tag for "img" omitted, but OMITTAG NO was specified.
.../scr/pixel.gif" width="1" height="1">

Line 51 column 0: start tag was here.
<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width=

Line 52 column 0: start tag was here.
<input type="hidden" name="encrypted" value="-----BEGIN PKCS7-----MIIH2QYJKoZIhv

Line 54 column 6: end tag for element "form" which is not open.
</form> </p>

mwinter
08-13-2006, 02:14 PM
When I check the XHTML code on the web ...

First of all, don't use XHTML on the Web unless you're serving it as an application of XML to specific user agents, like mobile devices. The Web needs less pseudo-XHTML, not more.


there is among other errors this one:


The character encoding specified in the HTTP header (windows-1252) is different from the value in the <meta> element (iso-8859-1). I will use the value from the HTTP header (windows-1252) for this validation.


But I can't find the entry (windows 1252) in the header.
Could someone please point this out to me so I can fix the error?

When a server returns a response containing an entity body (the message payload; image data, a style sheet, a HTML document, and so on), it should also return a Content-Type header. This specifies what type of data the response contains, and is authoritative; user agents must not attempt to second-guess the server if the header is present (though some badly-behaved agents do).

For the text/html MIME type, there is an optional parameter, charset, that states how the document has been encoded, and therefore how the user agents should proceed to map the data into the Universal Character Set (UCS; Unicode). Theoretically, if the character encoding information is missing, a user agent should assume ISO-8859-1, but there are so many badly- or unlabeled material on the Web that user agents have taken to guessing (somewhat intelligently) the encoding instead. Nevertheless, if a document is not ISO-8859-1, the server should be configured to state exactly what it is.

Regarding HTTP headers versus meta elements, the former always take precedence; if a user agent encounters both, it should ignore the latter. As such, the warning you received is telling you that the two conflict and so there's the possibility that the entity is mislabeled and problems might occur. There are two ways to fix it: modify the server settings (possibly through .htaccess files or similar means) to indicate ISO-8859-1, or re-encode the document to use Windows-1252. Either way, you should remove the meta element. I would choose the former: the latter is a proprietary encoding, and though well-supported, the former has better (it's an international standard).


And what is the difference between:
XHTML 1.0 Strict and XHTML 1.0 Transitional?

Transitional XHTML, just like Transitional HTML in that both define presentational attributes and elements. Neither was intended for long-term use, and some would say that Transitional XHTML was a mistake. No new document should use a Transitional document type without a very good reason.


... if I want to I can put the WC3 sign on every page.

And you don't want to: end-users neither care nor want to know. They shouldn't need to, either.


Line 39 column 91: required attribute "alt" not specified.

All img elements must have an alt attribute containing replacement text for that image. If the image was never rendered, what does the user need to know? If the image is decorative, the attribute value should be empty (alt=""). If it has meaning, what does it mean? For example, if it was a graph, what trends do the graph show?


Line 48 column 92: document type does not allow element "form" here; missing one of "object", "applet", "map", "iframe", "ins", "del" start-tag.

It appears that the parent element only allows in-line element content, not block-level elements. Check that you've nested the element correctly.

Following that message was the snippet:


...l.com/cgi-bin/webscr" method="post" />

If that is a form element start-tag, as the method attribute would suggest, then it should not be an empty element; the slash is an error.


Line 49 column 50: end tag for "input" omitted, but OMITTAG NO was specified.

Input elements have an EMPTY content model, and therefore they must be closed; you omitted the slash. The error that followed for the same line is a continuation of this error.


Line 50 column 82: there is no attribute "border".

The border attribute is not defined in the Strict document type. Use CSS, instead.

In decent browsers,


input[type="submit"] {
border: none;
}

would do what you want, but to support MSIE, you'll want to add an id attribute to the element and use an id selector (#...) instead.


Line 50 column 146: end tag for "input" omitted, but OMITTAG NO was specified.

That same input element is unclosed like the last one.


Line 51 column 95: end tag for "img" omitted, but OMITTAG NO was specified.

Like the two previous input elements, this img element is unclosed.


Line 54 column 6: end tag for element "form" which is not open.

As you included the form element using an empty element start-tag (due to that erroneous slash), the element is considered closed already and all of the elements up to this point have been siblings (not children) of the form.

Hope that helps,
Mike

Cheng
08-13-2006, 02:42 PM
Hi Mike.

Thanks for your reply.
I just mentioned it about the WC3 sign, I don't want it on my site.
Before your post came in I gave it a try and nearly finished it except for the last tag.
Please show me how to fix this last one here as I stuck on this one.

Thanks again.

Cheng

Here the error marked in red:
Line 55 column 6: end tag for element "form" which is not open.
</form>
And here te whole thing, I just cut the encrypted code in this post here:
<input type="hidden" name="encrypted" value="-----BEGIN PKCS7-----MIIH2QYJKoZIhvcNAQcEoIIHyjCCB8YCAQExggEwMIIBLAIBADCBlDCBjjELMAkGA1/a4SmMKS9CbBwj0L49QsSrxeb537HwnXPnYFdSGWdncJ1pJITACo7zIP0SkyQPjSPINGPPxMyt-----END PKCS7-----" />
</form>

mwinter
08-13-2006, 02:52 PM
As I pointed out, your form element start-tag looks something like:


<form action="https://www.paypal.com/cgi-bin/webscr" method="post" />

however that slash at the end of the start-tag makes this element empty; from the perspective of XML, this is exactly the same as:


<form action="https://www.paypal.com/cgi-bin/webscr" method="post"></form>

which is clearly not what you want. Remove that slash.

Note that if you are using a Strict DTD, the only acceptable children of form elements are script elements, and block-level elements. You'll either want to use a div or fieldset element (depending on how you want to structure the form):


<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<div>
<!-- ... -->
</div>
</form>

A paragraph isn't appropriate, in my opinion, unless the form controls appear as part of paragraph text. For example:


<p>Next month, you will be <input type="text" name="age" value="" /> years old.</p>

Mike

Cheng
08-13-2006, 03:04 PM
Hi Mike.

i appreciate you expaining all this but I sit in front of the screen for 15 hours now and I stuck just on this last one here.
Can you please show me how it must look like that it will validate and there are no shown errors anymore.
I tried every possible way to fix that tag but without luck.
do I need to do it like this ?
<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<div>
<!-- ... -->
</div>
</form>
Place the form tag outside the div tag?
I really don't get it.

Anyway thanks for trying to explain but this is the 1st time I'm working with a stylesheet and with this XHTML code and it is all very confusing still.

Thanks again.
cheng

Cheng
08-13-2006, 03:18 PM
Hi Mike.

......alright I got now.
The error is gone (green light)
Now I have the exactly the same thing to do for another button and than I made my 1st XHTML site without any error.

Thanks again very much.

Cheng

jscheuer1
08-13-2006, 08:45 PM
But, you seemed to have ignored both Mike and myself when we both said that you should change to HTML. Unless, as Mike mentioned, your pages are xml applications which, they probably are not:

First of all, don't use XHTML on the Web unless you're serving it as an application of XML to specific user agents, like mobile devices. The Web needs less pseudo-XHTML, not more.

Your document would probably be better off as regular HTML anyway.

mwinter
08-13-2006, 09:23 PM
do I need to do it like this ?


<form action="https://www.paypal.com/cgi-bin/webscr" method="post">
<div>
<!-- ... -->
</div>
</form>


Not exactly like that, no, but very close to it. The div element can be replaced by any block-level element, including paragraphs, fieldsets, and tables, but a block-level element (and/or a script element) is necessary.


Place the form tag outside the div tag?
I really don't get it.

All elements have a content model. This determines what can be used as a child of that element. Some elements like img and input have an EMPTY content model: they have no content at all. Others may include #PCDATA (text; non-element content), whilst others won't. For those that allow other elements, only a restricted subset of all the elements are permitted, and that subset varies from element to element. For example, paragraphs allow text and in-line elements. The body element permits only block-level and script elements. The div element allows text, in-line, and block-level elements.

As far as I can see, when the form element was defined for HTML 4, it was decided that the contents of the form should have an explicit structure. As such, a block-level element (or script element) like a table or fieldset element should be a child of the form. A table is good where there is a tabular relationship, as there are in many forms: one column has labels, another has controls, and related labels and controls are in the same row. The fieldset element is useful where the form can be split logically into sections, like personal details, interests, comments, etc. Each fieldset element must have a legend element as its first child, and this contains the title or heading for that section.

Beyond that, there isn't really much to "get": the elements in HTML are defined the way they are. It wouldn't much matter whether the content models were decided arbitrarily, or with purpose (though the latter is easier to work with :)); if you want your documents to be valid, you simply have to conform with those definitions.


Anyway thanks for trying to explain but this is the 1st time I'm working with a stylesheet and with this XHTML code and it is all very confusing still.

I don't mean to get negative, but if you're having this much trouble, it's likely that you don't understand XML, and that should be a prerequisite to using an application of the language, like XHTML. Knowing how user agents treat XHTML served as HTML is also critical, and needs to be well-understood, too.

There's nothing inherently better about XHTML, nor any rush to use it. After all, MSIE doesn't even support it. HTML will be around for a very long time, and a well-written HTML Strict document is trivial to mechanically convert to XHTML, should you ever decide to use it in the future. XHTML certainly isn't worth getting worked up over.



Your document would probably be better off as regular HTML anyway.

Sorry, John, I missed that.

Mike