Forum Moderators: open

Message Too Old, No Replies

Choosing XHTML over HTML

         

Ingolemo

4:29 pm on Feb 17, 2007 (gmt 0)

10+ Year Member




System: The following 2 messages were cut out of thread at: http://www.webmasterworld.com/css/3253940.htm [webmasterworld.com] by encyclo - 8:47 am on Feb. 18, 2007 (utc -5)


Please don't use XHTML 1.1 unless you're sending it as
application/xhtml+xml
(not recommended since IE doesn't support it).

SuzyUK

4:51 pm on Feb 17, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



duckxtales you are correct that is HTML. as long as it validates to an HTML Doctype there is nothing to worry about as far as CSS is concerned, which HTML doctype (or the absence of one) will have an effect on how IE renders though

XHTML is not much different from what you have it is just a good excercise in preparing for XML - mainly making sure all elements are closed like <br /> <img /> <p>some text</p> etc.. and making sure all tags and attributes are lowercase and that attributes are quoted. Then of course you need to pick an XHTML Doctype

but either way will do

The official term is XHTML/CSS. You should code XHTML 1.0 Transitional most of the time, and make your pages validate. This allows you to use a validator as a debugger. I usually code XHTML 1.1, because it isn't much more work than XHTML 1.0 Transitional, and I can do a bit more with 1.1 pages.

I beg to differ as usual, there is no such thing as an "official term" AFAIK? - you can code CSS for HTML just as well and using an HTML Doctype you can use the validator too - IMO there is no "should code XHTML whatever" about it ;)

The idea is to choose the tool (HTML/XHTML) for the job then pick the correct Doctype to go with it then you get into the minefield of content-types ... anyway if you are interested in finding out more about the whys and wherefores of that there was an excellent discussion a while back - Why most of us should NOT use XHTML [webmasterworld.com]

Just because a page validates XHTML it does not mean it's better than the same page coded as an HTML valid page - the person doing the coding and understanding why they are using one over the other .. now that's different :)

Suzy

[edited by: SuzyUK at 5:30 pm (utc) on Feb. 17, 2007]

cmarshall

8:28 pm on Feb 17, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member




System: The following message was cut out of thread at: http://www.webmasterworld.com/css/3253940.htm [webmasterworld.com] by encyclo - 8:48 am on Feb. 18, 2007 (utc -5)


Please don't use XHTML 1.1 unless you're sending it as application/xhtml+xml (not recommended since IE doesn't support it).

Actually, I do, but I check the accept first.

I like it because it is absolutely BRUTAL. Even tiny mistakes result in the page being completely fubar. It forces me to write very clean code.

In any case, I've been doing this for quite some time, and my sites render on a huge range of browsers, including IE5/Win98 (and sometimes IE5/MacOS).

Because my sites have to work on such a huge range of browsers, I usually keep the "pizazz factor" pretty low, which may explain why I haven't had any issues. They are real plain, real fast, real accessible, usually (but not always) real simple and real usable.

I mainly do it because it's a challenge. I consider things like that a glove on the ground. It's become habit now.

I guess I could swap out the DOCTYPE with almost zero effort if it ever became an issue.

Another big reason is that I'd like to start moving towards XML/XSLT coding, and using things like PHP's DOM Stuff [us3.php.net] to repackage my site pages into RSS and WML pages.

Until it costs my users or myself something, I'll keep doing it. If it does cost, then I'll adapt. That's always been my M.O.

[edited by: encyclo at 1:52 pm (utc) on Feb. 18, 2007]
[edit reason] tidying up [/edit]

cmarshall

1:37 pm on Feb 20, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Just for the record, I found my first case of why I can't use the application/xhtml-xml content-type.

I started using sessions in the administration code for one of my sites, and the server was kind enough to affix a &PHPSESSID= to all of my links on the first page of the session. This is apparently done en route from the Web server to the browser, so my ob_ code cleaner can't get it.

This makes the browser go running for the porcelain convenience ("Badly-Formed" -doesn't like the "&"), so I had to back all my stuff on that site down to XHTML 1.0 Transitional and stop spitting out the header.

Robin_reala

11:03 pm on Feb 20, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



a) Ouch. Sounds like you need to change hosts, or figure out what’s going wrong with your setup.

b) why Transitional? Strict would be a better fit here, especially if you’re used to coding XHTML1.1.

cmarshall

11:46 pm on Feb 20, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



a) Ouch. Sounds like you need to change hosts, or figure out what’s going wrong with your setup.

Yup. I need to do some research. It only happens on my host's Apache server; not on my test server. I have a feeling it has something to do with the fact there's a hundred other sites on that server.

It's the weirdest damn thing. I scrub my HTML by grabbing it all in ob_* functions and running it through some regex functions. The &PHPSESSID isn't there when I do that, but it is there when I show the code for the page in the browser. I figured that when you echo, it goes straight to the browser. Guess not. Maybe there's something whacky with my regexes. I'll work on it a bit more...

This only happens on the first page of the session. Subsequent pages don't have it, even if I leave the site and come back, so they are tied to the browser session.

b) why Transitional? Strict would be a better fit here, especially if you’re used to coding XHTML1.1.

Yup. Transitional was easier. But I'm stubborn. I slammed all the pages back to 1.1, and skip outputing the header if it's the first page of the session. Means that I have one broken validation, but I can live with that.

PowerUp

8:15 am on Feb 21, 2007 (gmt 0)

10+ Year Member



Hi guys, I have a newbie question.
I downloaded a free template that I want to use for my website. Seems that the DTD in that template is XHTML1.1 Strict.

My question is, will older browsers such as IE5 onwards be able to display the information of my website?

I don't have any fancy tags. Just the normal </p>, <br />, <strong>, <ul>, <li> + CSS.

cmarshall

11:33 am on Feb 21, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



There's no such thing as 1.1 Strict. It is probably 1.0 Strict. The syntax is virtually the same.

1.1/1.0 Strict will work for me for a whole slew of browsers, including IE5/Win and IE5/Mac. It depends on how fancy I get with the XHTML elements and the CSS, which can break old browsers, even with HTML 4.01 Transitional.

PowerUp

4:15 pm on Feb 22, 2007 (gmt 0)

10+ Year Member



hi cmarshal, this is the DTD in my html. It says xhtml1.1

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

is it strict?

cmarshall

4:59 pm on Feb 22, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



That's 1.1. It's about as strict as they make 'em, but is not actually "strict," per se. It's just good ol' 1.1.

The official story about 1.1 is that you should tell the browser the content-type is "application/xhtml+xml," if the browser will accept it.

Generally, if you won't do that, then use XHTML 1.0 Strict (basically, the same syntax, but a different DOCTYPE).

If the code will validate 1.1, then it will validate 1.0 Strict, so you can just swap out the DOCTYPE.

Here is the DTD for 1.0 Strict:

<!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" xml:lang="en">

PowerUp

2:53 am on Feb 23, 2007 (gmt 0)

10+ Year Member



mmmm? I don't understand what you say. And I will probably get more confused if you try to explain more. For now, which is better? 1.0 strict. Or 1.1?

cmarshall

2:59 am on Feb 23, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



For now, which is better? 1.0 strict. Or 1.1?

1.0 Strict.