XHTML Compliance 

Monday, February 20, 2006 4:50:14 PM
Rate this Content 0 Votes

I've been working hard on getting mojoPortal to XHTML compliance and I'm happy to report that now almost every page is valid XHTML 1.0 Transitional according to the W3C Validator. Some pages would even validate as XHTML 1.1 but since the FCKeditor only supports 1.0 I decided to use the 1.0 doctype. In .NET 1.1 is was not possible or at least very difficult to get XHTML compliance because the server controls in 1.1 were not intended to emit XHTML but now 2.0 .NET makes it all possible. I had to fix one minor bug in the .NET wrapper for FCKeditor to get it to validate correctly.

One thing about ASP.NET is that the server controls are built to downgrade gracefully on legacy browsers so if it can't detect the browser it will not render as XHTML which made it not validate just by pointing the validator at my site. Then thanks to google I found Barry Dorran's blog post where he created a w3cvalidator browser definition file for 2.0 .NET. You just drop it in your App_Browsers folder and recompile, then you can point the w3c validator at your site and it will render as it would for a high level browser, or in other words XHTML.

Until I got the browser definition in place I had to view the page in a browser like Firefox and then right click to get the source, save to disk and upload it to the validator but now with the link it is easy to find the pages that still need some work.

So I thought it might be interesting to survey the sites of some competing ASP.NET portal and framework projects and here is what I found:

Community Server uses XHTML 1.0 Frameset for the DOCTYPE and the validator reports 76 errors

DotNetNuke uses HTML 4.0 Transitional for the DOCTYPE and the validator says 148 errors

Rainbow Portal uses HTML 4.0 for the DOCTYPE and the validator reports 84 errors

interestingly even the ASP.NET site doesn't validate, it uses XHTML 1.0 Strict for the DOCTYPE and the validator finds 168 errors

I used Firefox to get the page source in testing each of these.

To be fair I have to say that the current releases of mojoPortal probably don't fare well at the validator either but the next release of the 2.x branch will be compliant. This site and mojoportal.com are running on the latest mojo code from svn and they are both validating nicely on most pages and thats something even the big boys can't say right now
Valid XHTML 1.0

Share This Using Popular Bookmarking Services

re: XHTML Compliance

Monday, February 20, 2006 9:24:34 PM na
Is this some kind of joke? Have you looked at the generated XHTML sources?
<a id="ctl00_mainContent_ctl01_dlArchiveRight_ctl02_Hyperlink6" href="http://www.mojoportal.com/BlogArchiveView.aspx?&amp;month=12&amp;year=2005&amp;mid=19&amp;pageindex=&amp;pageid=2" style="display:inline-block;border-width:0px;border-style:None;font-size:Small;font-weight:normal;font-style:normal;text-decoration:underline;">December, 2005 (4)</a>
I'll overlook the use of presentational tables, but what is with the id, class and style attributes? They're completely non-semantic, and even then, ridiculously long and even wasteful of bandwidth.

XHTML is only useful if you use it properly. This output is no better than passing junk HTML through htmltidy with the -xhtml option.

I hope you're working on making the output semantic. I might be far less scathing when I see that. Have just been upset to see some of the backward HTML that ASP.NET sites generate compared to the rest of .NET which is pretty sane.

re: XHTML Compliance

Monday, February 20, 2006 9:27:40 PM na
Even worse!

text/html

The page is being served up as Content-type: text/html

It has been argued that this practice alone is killing the adoption of XHTML.

This is very bad indeed. The previous post was nit-picking, but you really do need to send out the right content-type when sending XHTML.

re: XHTML Compliance

Tuesday, February 21, 2006 3:02:51 AM Joe
Settle down Mr Anonymous,

I'll look into the content type issue that should be very easy to change if it needs to be.

Sure the ASP.NET menu uses table layout. XHTML has no rule against that and when I have a spare man/year maybe I'll write my own menu that renders html that looks nice and meets your approval. Or better maybe you could work on that and contribute something constructive.

In the meantime I still pass the W3C Validator and regardless of your attiude that makes me happy. I didn't say I solved world peace or achieved being "semantic", just that I got my sites to pass the validator which is better than many sites.

re: XHTML Compliance

Tuesday, February 21, 2006 6:33:16 AM Aaron King

I'm biased so all the sceptics will chew me a good one.  I think it is a great feet to get the base install of MP compliant.  It will point people in the right direction and not hinder them like the big boys have done.

The table issue is just preference really.  I mean if you prefer to get all CSS Zen on us MPers fine.  Anyway.. GREAT JOB, JOE.


re: XHTML Compliance

Tuesday, February 21, 2006 6:34:02 AM Aaron King
yes.. i can't spell.

re: XHTML Compliance

Tuesday, February 21, 2006 7:04:31 AM Daniel Veillard
XHTML compliance requires first XML compliance. I tested the first of the link with xmllint, it's not XML, so it can't
be XHTML. The fact it being served as text/html may fool the validator, but it;s definitely not well formed, just
try xmllint --noout your_web_page until it stop spewing errors, then use xmllint --valid --noout your_web_page
to remove the validity errors in the generated output. But until the first test passes it's just not XML and hence
just not XHTML.

Daniel Veillard

re: XHTML Compliance

Tuesday, February 21, 2006 7:35:36 AM Joe
Well I changed the Content Type to application/xhtml+xml and the W3C Validator still seems to be fooled

Joe

re: XHTML Compliance

Tuesday, February 21, 2006 9:48:26 AM Joe
Daniel,

When you tried with xmlint did you just point it at an url or did you view the source in an uplevel browser and save it to disk and then run xmlint?

If you just point it at the url it won't work because if .NET can't detect the browser it renders downlevel which won't be valid.
If you get the source using Firefox I would think it should be valid xml and valid XHTML.

Cheers,

Joe

re: XHTML Compliance

Wednesday, February 22, 2006 6:54:28 AM Dan Shryock
Just thought I'd mention that in the future, if you run into a situation where the validator can't get to your content, you can use the HTML Validator plugin to firefox which will show you validation results as the page loads or full details by viewing the source.  And all of this is without contacting external services.  And to put to rest all of the dumbasses complaining about text/html, ONLY xhtml strict requires the change in doc type and it is recommended that transitional and text/html should be used for most average sites.  And as a side note, after retreiving the content, every xml parser I threw at it considered it valid :P

re: XHTML Compliance

Sunday, March 12, 2006 9:05:30 AM Asbjørn Ulsberg
I want to comment "If you just point it at the url it won't work because if .NET can't detect the browser it renders downlevel which won't be valid". This itself is so insane that I don't know where to start. It goes against the very foundations of HTML (and XHTML) in so many ways that it's scary. To even think about sniffing the User-Agent-string and do anything with it is extremeley short-sighted at best. To actually base HTML rendering upon it is exploding madness. Now, I know that it's the ASP.NET framework that does this for you, but if it's possible to turn off, I suggest that you do it immediately. It's very good that you try to stay compliant to XHTML, but validating as XHTML 1.0 Transitional isn't all that swell. It's just HTML 4.01 Transitional, wrapped in XML syntax. You're still allowed to use HTML for design and all that derecated stuff, which goes against all of W3C's recommendations. Using tables for layout is a big "no no" and it's plain obvious that a list (UL or OL) should have been used instead for the tree control. The good thing about this is that there are a lot you can do to fix this. You can write HTML output filters to remove all unecessary attributes like 'id' and 'style' on elements where these aren't used in client-side scriptnotalloweding or stylesheets. You can check for the existance of 'application/xhtml+xml' in the 'Accept'-header of the client and if it exists, output your XHTML as exactly that instead of 'text/html'. You should also use the 'XHTML 1.0 Strict' DOCTYPE instead of the 'XHTML 1.0 Transitional' DOCTYPE. The word 'Transtitional' means that your markup is in a transition between the "oldschool markup" where the design was embedded in the HTML itself and the "newschool markup" where design was placed in nice little stylesheets. If you're using CSS-based layout, there's no need to express that you're in that transition anymore, since you're not. Use 'Strict' instead. Also, using XHTML 1.0 instead of 1.1 allows you to output your XHTML as 'text/html'. XHTML 1.1 should not be outputted as 'text/html' ever. It's not allowed. XHTML 1.0 (with whichever DTD) supports 'text/html' and thus is a more backward-compatible (read "Internet Explorer compatible") DOCTYPE.

re: XHTML Compliance

Monday, March 13, 2006 5:52:29 AM Joe Audette
Well I have to admit I question the reasoning that an unknown browser should be assumed to be downlevel. It seems like it might make more sense to assume the opposite, that an uknown browser is newer and therefore probably standards based.

However I don't agree that detecting the browser and trying to determine its capabilities to provide the best possible experience is a bad idea. I think that is a good idea. It raises the possibility of rendering better in a wide variety of browsers from cell phones on up.

My main reason for going with the transitional dtd is becasue of the FCKeditor I'm using in my project. It relies on iframe which I don't think is allowed in strict, or is it? I'm fairly certain its not allowed in 1.1

I don't grok why the id attribute is considered a bad idea, it is certainly helpful in postbacks to the server.

I'm all for supporting the standards but I also am pragmatic and realise that not all popular browsers are standards compliant yet. Maybe some out there don't care about supporting IE but I do. I wish it were more standards compliant but its not and thats the state of affairs in the real world at the moment.

Comments are closed on this post.
Donate Money to support the mojoPortal Project. View Joe Audette's profile on LinkedIn View Joe Audette's profile on The Guild of Accessible Web Designers site