I want html, not xhtml from my aspnet controls

J

j.madgwick

I'm confused. I've been trawling the web and can't find the
answer...

The background: I am working on a MCMS site with ASPNET 1.1.4322. We
want the site to be written in standard compliant HTML that passes the
W3C validator.

The problem: ASPNET controls are generating HTML with xHTML
self-closing tags. Eg. <img id="Image1" alt="" border="0" /> and <input
type="hidden" name="__EVENTTARGET" value="" />

A solution: I have read that you can use <xhtmlConformance
mode="Legacy" /> in your web.config to control the type of HTML
generated by an ASPNET control, but this is a feature of ASPNET 2.0, we
are using 1.1.

The confusion: From what I have read on the web, ASPNET 1.1 does *not*
produce any xHTML code. Every article is about getting xHTML not
getting rid of it! So, where are the closing tags coming from? Could
it be part of a Service Pack or other windows/accessibility upgrade? I
mention accessibility because I've noticed that it also puts a empty
alt attribute into my img tags automatically too.

Any information would be appreciated.
Thanks,
John.
 
B

Brennan Stehling

John,

What is your problem exactly? You do not want the empty alt tags or
closing tags?

The empty alt tag is required if you specify a certain DTD for HTML.
That is not just for XHTML. And the self closing tags... <br /> and
<img /> will not cause legacy browsers to display the page incorrectly.
It is not clear that the HTML validators will have a problem with them
either. While this is an XHTML requirement, you may find that this is
encouraged with the HTML 4 specification. You can see the official
recommendation here...

http://www.w3.org/TR/xhtml1/#guidelines

Look at C.2. It explains to ease gradual migration from legacy HTML to
XHTML the BR and IMG tags should include the self-closing feature.
More here...

http://en.wikipedia.org/wiki/HTML#Current_flavors_of_HTML
http://en.wikipedia.org/wiki/HTML#Traditional_versus_XML-based_HTML

I also wrote this last year which you may find useful.

Why not XHTML Strict?
http://brennan.offwhite.net/blog/2006/01/25/why-not-xhtml-11-strict/

I also suggest keeping an eye on this website...

http://alistapart.com/

Brennan Stehling
http://brennan.offwhite.net/
 
J

j.madgwick

Hi Brennan,
Thank-you for your response.
My problem is my version of ASPNET 1.1 is producing xHTML (with
self-closing tags) when I was expecting it to produce HTML (without
self-closing tags).

Originally, we were going to create the site in xHTML 1.0 Transitional,
but we're using Microsoft CMS and can't get the bugger to produce
valid xHTML. Therefore, we decided to go with HTML 4.0 Strict.
Unfortunately, it has left us in a bit of limbo because tags produced
by CMS are HTML and the ASPNET ones are xHTML. So, in the source code
it looks as if we can't decide which one we want to use!

You are right about the validator. It was not the self-closing tags
causing the errors, so I guess this is a bit of a non-issue that I can
live with now, but it is still annoying.

We always use alt tags in our img tags so this was not the problem. I
just mentioned it above because when I was doing some testing I
wasn't expecting ASPNET to drop it in automatically. I thought it
may be a clue towards a Service Pack that may have affected the output
code.

BTW: Nice article.

Thanks again,
John.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top