Forum Moderators: open

Message Too Old, No Replies

XHTML sites. and changing back to HTML

any downsides?

         

londrum

10:05 pm on Mar 15, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



i used to be a bit of a cheerleader for XHTML... every page on my site validated against xhtml strict. i even had it delivering the correct application-type header to firefox users.
but after finally listening to a load of people say the opposite, and reading about it too, i've changed my entire site back to HTML again.

and now, for the life of me, i can't figure out what i ever saw in it. what is the big hoo-haa about xhtml?
the only benefit i can see to it now is that it encourages better coding.

but strict HTML allows you to cut your page weight massively. no more closing slashes on tags, no more

</li>'s
,
</td>'s
,
</dd>'s
and
</dt>'s
etc.

i can't see any downsides at all to changing back to HTML. anyone know any?

DrDoc

3:48 am on Mar 16, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Please change back to HTML!
But please keep the closing tags!

Although they are not technically needed to validate as HTML, they help keeping the code cleaner, reduce the guesswork for the UA, are cleaner and easier to parse, AND are more likely to be compatible with future markup versions.

mattur

4:38 am on Mar 16, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I personally prefer lean markup and omitting most optional closing tags, but it depends on the project and who will be maintaining the code. I do always use <html>, <head> and <body>.

reduce the guesswork for the UA, are cleaner and easier to parse

You're right, because there are some browser bugs to watch out for, but as long as you browser test (which you have to anyway when using CSS) it shouldn't be a problem.

AND are more likely to be compatible with future markup versions

It's very unlikely that new versions of HTML will change the current syntax rules imho.

i can't see any downsides at all to changing back to HTML. anyone know any?

You can't easily include MathML, SVG etc. As long as you don't need to do this: no drawbacks.

DrDoc

4:40 am on Mar 16, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It's very unlikely that new versions of HTML will change the current syntax rules imho.

They are likely to require closing tags for all elements. Maybe not necessarily short-tag syntax ... but closing tags for things like <p> <tr> <td> <li>

MarkFilipak

4:42 am on Mar 16, 2008 (gmt 0)

10+ Year Member



According to the HTML spec., closing tags are required for nearly all HTML elements. For consistency, I think they should be required for all HTML elements but, of course, they are actually forbidden for some.

I have a related question: Opera -- yes, I know there's an Opera forum in WebmasterWorld -- complains about one particular page of html strict saying that it is not xhtml. I have to add the closing slash to those elements that don't take a closing tag and, this is strange, I have to put a space between attributes (example: instead of onload='blah'onmouseover='blah', I have to have onload='blah' onmouseover='blah'). Have you guys run across this and what is the relationship between attributes without whitespace and xhtml?

Edit update:

I just took a look at HTML 4.01. I never noticed that for so many elements, a closing tag is optional -- but I guess you gurus knew that -- I just automatically put them in.

[edited by: MarkFilipak at 4:53 am (utc) on Mar. 16, 2008]

DrDoc

4:53 am on Mar 16, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Omitting the space is invalid HTML.
Straight from the HTML 4.01 spec:
Any number of (legal) attribute value pairs, separated by spaces, may appear in an element's start tag. They may appear in any order.

MarkFilipak

5:00 am on Mar 16, 2008 (gmt 0)

10+ Year Member



> Omitting the space is invalid HTML.
Thanks, Doc! It's silly of course as the closing quote-char should act as a fine delimiter, but I can't argue against a specification. Guess this should teach me not to make assumptions.

DrDoc

5:04 am on Mar 16, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



... except that in HTML the delimiters are optional for attributes ;)

For example, border=1 and border="1" are equally valid.

But, let me tell you this -- from years of experience -- that nothing bad has ever come out of being consistent. I always quote (using double quotes) all attributes, and I always use closing tags where available.

Quite contrary ... it has caused headache when people have not done so, making assumptions about the surrounding markup or values of given attributes.

The benefit from XHTML is just that -- clean markup. But there's nothing preventing us from having that same clean markup while utilizing HTML. In fact, it is preferred to do so.

tedster

5:08 am on Mar 16, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



...use closing tags where available

I started doing this years ago because older browsers sometimes NEEDED the closing tag to render the element properly. Even as late as Netscape 4.0 (yes, I'm old) you needed to close a <p> tag to get proper right alignment.

DrDoc

5:13 am on Mar 16, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It also makes find-and-replace much easier.

I once had a situation where I needed to replace certain <p> (without closing tags) with <span> or <div> ... Seeing how this was a large site with thousands and thousands of pages, the process became entirely manual and extremely tedious.

mattur

5:51 pm on Mar 16, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



[New versions of HTML] are likely to require closing tags for all elements.

Hi DrDoc,
The HTML5 Draft retains [w3.org] the current rules on optional end (and start) tags. What makes you think HTML6+ will change this?

DrDoc

6:50 pm on Mar 16, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



My comment is taken slightly out of context ...

The initial statement was that by including optional closing tags, and always using double-quoted attributes, the produced markup is "more likely to be compatible with future markup versions" ... such as XHTML/XML/etc.

I realize that the next poster then responded by limiting the applicability to plain HTML, which then caused my initial intentions behind the statement to be misunderstood.

The fact of the matter is that W3C is moving closer and closer to the stricter XML type syntax. Even HTML5 itself proves this by being extremely detailed with regards to when and when not end tags are optional. Anything that simplifies the syntax is good for both developers and UA providers alike. Strict markup and strict development habits are superbly beneficial, even if not currently realized.

Don't let short term gain blind you from the long term benefits. Of course, it is up to each of us to determine where the future is going to take us, and thereby evaluate the needs carefully. However, if that path is yet uncertain, the decision to always include optional closing tags and always use double-quoted attributes might be the most suitable.

[edited by: DrDoc at 6:51 pm (utc) on Mar. 16, 2008]

Fotiman

3:09 pm on Mar 17, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



londrum, like you, I also jumped on the XHTML bandwagon long ago. But eventually, I came to the same conclusion as you (and many others) and switched back to HTML. I will say, though, that I'm quite happy that I made this progression from HTML to XHTML and back to HTML again because I picked up a lot of really good coding habits from developing in XHTML. In fact, that's what I usually tell others who are interested in developing in XHTML... it's great to use it for a while, but switch back to HTML later and take those great coding practices and apply them to HTML.

I close all of my tags now (except for those that don't have closing tags in html: img, meta, link, etc.). My code is cleaner and easier to read and maintain. I would re-iterate what DrDoc said...

Please change back to HTML!
But please keep the closing tags!

mattur

5:47 pm on Mar 17, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The fact of the matter is that W3C is moving closer and closer to the stricter XML type syntax.

To be clear: HTML5 is not moving closer to the stricter XML type syntax. HTML5 retains the current HTML rules on optional opening and closing tags. Valid HTML4.01 will be conformant HTML5, with a few small exceptions (some presentational attributes have been removed).

Even HTML5 itself proves this by being extremely detailed with regards to when and when not end tags are optional.

HTML5 retains the current rules but precisely defines them (and all the other rules) for the first time. Only XHTML5 requires well-formed XML syntax, though I do accept that closing non-empty tags in HTML is a widespread de facto standard. Incidentally, HTML5 also allows closing empty tags too i.e. <img ... /> and <img ... > are both conformant HTML5.

g1smd

10:51 pm on Mar 17, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Be aware that using the <meta name="...." content="...." /> format closing tag on <meta>, <img>, <hr>, <br>, and so on, along with an HTML 4.01 DOCTYPE can cause interesting issues.

Avoid that format with HTML 4.01, especially with <meta> tags.

Do use closing tags on paragraphs, lists, and tables. You can sometimes get interesting CSS style bleed-over effects if you miss some out.

Dave75

5:00 pm on Mar 20, 2008 (gmt 0)

10+ Year Member



The decision between HTML and XHTML is now mostly about the back-end. How do you store, validate, assemble and transmit data? XML provides some very neat solutions to these issues which, is why XHTML can be a good choice for your markup.

Once we see better support for XSTL the choice should be to go from XHTML to XML, not back to HTML.

pageoneresults

5:09 pm on Mar 20, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Don't Switch Back!

If you plan on using any third party applications and want to merge them seamlessly with your new site and have it validate too, then I do believe your best option now is to stick with the XHTML. Yes? No?

I too jumped on the XHTML bandwagon. Switched one site back to HTML 4.01 Strict and then switched it back to XHTML 1.0 Strict. Arrrggghhh! Make up your minds, would ya? ;)

JAB Creations

8:16 pm on Mar 20, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



One beautiful aspect of XHTML when served as application/xhtml+xml is that you can emulate other versions of languages that are themselves incompetent (HTML5) but implement some of their useful features (such as the ping attribute on anchor elements).

- John