Re: Margin attributes not accepted by XHTML 1.0 & impossible to validate CSS

Benoit Quemar wrote:
> My draft page here can only be validated with XHTML 1.0 if I REMOVE the two
> topmargin & left margin attributes within the <body> tag:

You mean body element, it's not a tag.
http://lachy.id.au/log/2004/12/html-tags

> http://altamedia.ca/home/index2b.htm

You can use CSS to set the margins instead.

body { margin-top: 0; margin-top: 0; }

> I’ve looked at many support webpages and I don’t understand why I can’t just
> leave the attributes in place.

Because they're non-standard proprietary extensions added by Microsoft.

> Also, when I try to validate my CSS, your system tells me to validate my
> XHTML first, which I did (and passed after removing the tags).

I think you mean after removing the attributes, not tags.

> http://jigsaw.w3.org/css-validator/validator?uri=http%3A%2F%2Faltamedia..ca%2
> Fhome%2Findex2c.htm

No, it's actually a known limitation with the markup validator not 
reporting a well-formedness error when it should.  This line has the error:

<meta http-equiv="Content-Type"content="text/html; charset=iso-8859-1"/>
                               ^^^
You need a space between the quote and the next attribute.  Omitting the 
space would be valid (though not recommended) in SGML and HTML, but not 
in XML and XHTML.

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>

However, since you are using XHTML, there are several problems with this:

* XHTML documents should not really be served as text/html.
* XHTML should be served as application/xhtml+xml or application/xml.
* The meta element is absolutely useless in an XHTML document when
   served with the correct MIME type.  Don't even bother changing the
   value in the meta element, it will have no effect.
* The charset of the document should be set in the HTTP headers for an
   HTML document, and with the XML declaration for an XML document
   (assuming the correct MIME type is being used)

In other words, don't use the meta element and configure your server 
properly.


Your current HTTP headers contain:

   Content-Type: text/html

If you are going to continue to use XHTML, it should be changed to:

   Content-Type: application/xhtml+xml

(the charset will be determined from the XML declaration in the file)

Doing that with the above error in the file will result in a 
well-formedness error when viewed with a browser like Firefox, Mozilla 
or Opera.  If you change the file extension to .xhtml instead of .html, 
and load the file from your local file system, that will have the same 
effect in those browsers.

However, that *will not* work in IE, it will only result in a save as 
dialog box being presented to the user.  For this, and many other 
reasons I don't have time to explain, I recommend you switch to HTML 
4.01 and fix the content-type header like this:

   Content-Type: text/html; charser=ISO-8859-1

See the full HTTP headers of your document:
http://cgi.w3.org/cgi-bin/headers?url=http%3A%2F%2Faltamedia.ca%2Fhome%2Findex2c.htm

See also:
http://www.hixie.ch/advocacy/xhtml

Since the headers say you are using IIS, I don't know how to configure 
it properly to include a charset parameter.  Consult the documentation 
for IIS to learn how to use it properly.

> How can I keep the attributes that I need and still being validated?

You don't need them.

-- 
Lachlan Hunt
http://lachy.id.au/
http://GetFirefox.com/     Rediscover the Web
http://GetThunderbird.com/ Reclaim your Inbox

Received on Tuesday, 12 April 2005 03:34:20 UTC